Subject: changeset in modules/stock_consignment:5.0 Clear origin when copying 
move
From: Cédric Krier <[email protected]>

changeset 2247486feb05 in modules/stock_consignment:5.0
details: 
https://hg.tryton.org/modules/stock_consignment?cmd=changeset;node=2247486feb05
description:
        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
        (grafted from 6720c66ab49cbae633f574e20338752aa04231f3)
diffstat:

 stock.py |  15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diffs (25 lines):

diff -r 26d57d14b0a0 -r 2247486feb05 stock.py
--- a/stock.py  Sat Jan 26 01:12:04 2019 +0100
+++ b/stock.py  Thu Jan 24 21:38:47 2019 +0100
@@ -241,6 +241,21 @@
     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'

Reply via email to