From 3acd5d0fbfb7ba7017c497ea8ffb04b3e6a05899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 9 Oct 2022 13:22:59 +0200 Subject: [PATCH] Remove conflicted definition of invoice_lines field on stock move invoice_lines is already defined by account_invoice_stock but as a Many2Many but as consignment invoice lines are filled also the stock_moves, they appears also on the Many2Many. So we can use the invoice_lines from account_invoice if we check the origin. issue11766 review421831003 --- stock.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/stock.py b/stock.py index 3db62ae854..f62a29fa63 100644 --- a/stock.py +++ b/stock.py @@ -65,7 +65,7 @@ def set_origin_consignment(func): to_save = [] move2line = {} for move in moves: - if not move.invoice_lines: + if all(l.origin != move for l in move.invoice_lines): lines = move.get_invoice_lines_consignment() if lines: to_save.extend(lines) @@ -93,7 +93,7 @@ def unset_origin_consignment(func): for invoice_line in move.invoice_lines: if invoice_line.origin == move: lines.append(invoice_line) - if isinstance(move.origin, InvoiceLine): + if move.origin == move: move.origin = None to_save.append(move) if lines: @@ -106,9 +106,6 @@ def unset_origin_consignment(func): class Move(metaclass=PoolMeta): __name__ = 'stock.move' - invoice_lines = fields.One2Many( - 'account.invoice.line', 'origin', "Invoice Lines", readonly=True) - @fields.depends('state', 'from_location', 'to_location') def on_change_with_unit_price_required(self, name=None): required = super().on_change_with_unit_price_required(name)