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

changeset fdf9bb48edc4 in modules/stock_consignment:4.8
details: 
https://hg.tryton.org/modules/stock_consignment?cmd=changeset;node=fdf9bb48edc4
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 474249e9cd56 -r fdf9bb48edc4 stock.py
--- a/stock.py  Sat Jan 26 01:12:51 2019 +0100
+++ b/stock.py  Thu Jan 24 21:38:47 2019 +0100
@@ -244,6 +244,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

Reply via email to