changeset f6a1d54cbab7 in modules/sale_amendment:6.2
details: 
https://hg.tryton.org/modules/sale_amendment?cmd=changeset&node=f6a1d54cbab7
description:
        Delete stock moves from components when applying amendment

        issue11355
        review386301002
        (grafted from b6a221e5d224b438d1576f80ef9e201e20193321)
diffstat:

 sale.py |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 0911711c6e77 -r f6a1d54cbab7 sale.py
--- a/sale.py   Mon Nov 01 17:28:11 2021 +0100
+++ b/sale.py   Wed Apr 06 18:52:08 2022 +0200
@@ -152,9 +152,7 @@
                 for invoice_line in line.invoice_lines:
                     if invoice_line.invoice_state == 'draft':
                         invoice_lines.add(invoice_line)
-                for move in line.moves:
-                    if move.state == 'draft':
-                        moves.add(move)
+                moves.update(cls._stock_moves(line))
 
         shipments_waiting = [s for s in shipments if s.state == 'waiting']
         Shipment.draft(shipments)  # Clear inventory moves
@@ -168,6 +166,12 @@
         ShipmentReturn.delete(
             [s for s in shipment_returns if not s.incoming_moves])
 
+    @classmethod
+    def _stock_moves(cls, line):
+        for move in line.moves:
+            if move.state == 'draft':
+                yield move
+
 
 class AmendmentLine(ModelSQL, ModelView):
     "Sale Amendment Line"

Reply via email to