From 0b58af3b222bdadb057111715723cf940847d682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 3 Feb 2026 10:20:59 +0100 Subject: [PATCH] Add searcher to the shipments field on invoice line --- modules/account_invoice_stock/account.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/account_invoice_stock/account.py b/modules/account_invoice_stock/account.py index e9e32c220d..0be7702f29 100644 --- a/modules/account_invoice_stock/account.py +++ b/modules/account_invoice_stock/account.py @@ -68,7 +68,10 @@ class InvoiceLine(metaclass=PoolMeta): (Eval('type') != 'line') | ~Eval('product')), }) - shipments = fields.Function(fields.Char("Shipments"), 'get_shipments') + shipments = fields.Function( + fields.Char("Shipments"), + 'get_shipments', + searcher='search_shipments') correction = fields.Boolean( "Correction", states={ @@ -114,6 +117,23 @@ class InvoiceLine(metaclass=PoolMeta): m.shipment.rec_name for m in self.stock_moves if m.shipment} return ', '.join(sorted(shipments)) + @classmethod + def search_shipments(cls, name, clause): + pool = Pool() + Move = pool.get('stock.move') + _, operator, operand, *extra = clause + if operator.startswith('!') or operator.startswith('not '): + bool_op = 'AND' + else: + bool_op = 'OR' + domain = [bool_op] + for shipment, _ in Move.get_shipment(): + if shipment: + domain.append( + ('stock_moves.shipment.rec_name', + operator, operand, shipment, *extra)) + return domain + @classmethod def on_modification(cls, mode, lines, field_names=None): pool = Pool()