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'