From b59b22721878e89b328de5941a282cbaad90fb0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 24 Jan 2019 21:38:47 +0100 Subject: [PATCH] Clear origin when copying move If the copy is not a split, we should remove the invoice line origin as it is new move that should be invoiced. issue7657 review64531002 --- stock.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/stock.py b/stock.py index f5e5809cc6..74ac338fed 100644 --- a/stock.py +++ b/stock.py @@ -248,6 +248,21 @@ class Move(metaclass=PoolMeta): def cancel(cls, moves): super(Move, cls).cancel(moves) + @classmethod + def copy(cls, moves, default=None): + pool = Pool() + InvoiceLine = pool.get('account.invoice.line') + moves = super(Move, cls).copy(moves, default=default) + if not Transaction().context.get('_stock_move_split'): + to_save = [] + for move in moves: + if isinstance(move.origin, InvoiceLine): + move.origin = None + to_save.append(move) + if to_save: + cls.save(to_save) + return moves + class ShipmentInternal(metaclass=PoolMeta): __name__ = 'stock.shipment.internal'