Add searcher to the shipments field on invoice line

This commit is contained in:
Cédric Krier
2026-02-03 10:20:59 +01:00
parent 86bc62d126
commit 0b58af3b22
+21 -1
View File
@@ -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()