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
This commit is contained in:
Cédric Krier committed 2022-10-09 13:22:59 +02:00
1 parent 6ca108ed77
commit 3acd5d0fbf
1 file changed
+2 -5
+2 -5
View File
@@ -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)