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
This commit is contained in:
Cédric Krier committed 2019-01-24 21:38:47 +01:00
1 parent d92b2c0c47
commit b59b227218
1 file changed
+15
+15
View File
@@ -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'