changeset 2891dadc2165 in modules/product_kit:6.0
details: 
https://hg.tryton.org/modules/product_kit?cmd=changeset&node=2891dadc2165
description:
        Delete stock moves from components when applying amendment

        issue11355
        review386301002
        (grafted from ffeafe1cbe9fa2dce255157936cfae676d07ebe7)
diffstat:

 __init__.py |   2 ++
 purchase.py |  12 ++++++++++++
 sale.py     |  12 ++++++++++++
 3 files changed, 26 insertions(+), 0 deletions(-)

diffs (60 lines):

diff -r 8d5e1d1e94f6 -r 2891dadc2165 __init__.py
--- a/__init__.py       Mon Mar 21 16:05:11 2022 +0100
+++ b/__init__.py       Wed Apr 06 18:52:08 2022 +0200
@@ -37,6 +37,7 @@
         sale.HandleShipmentException,
         module='product_kit', type_='wizard', depends=['sale'])
     Pool.register(
+        sale.Amendment,
         sale.AmendmentLine,
         module='product_kit', type_='model', depends=['sale_amendment'])
     Pool.register(
@@ -52,5 +53,6 @@
         purchase.HandleShipmentException,
         module='product_kit', type_='wizard', depends=['purchase'])
     Pool.register(
+        purchase.Amendment,
         purchase.AmendmentLine,
         module='product_kit', type_='model', depends=['purchase_amendment'])
diff -r 8d5e1d1e94f6 -r 2891dadc2165 purchase.py
--- a/purchase.py       Mon Mar 21 16:05:11 2022 +0100
+++ b/purchase.py       Wed Apr 06 18:52:08 2022 +0200
@@ -132,5 +132,17 @@
     __name__ = 'purchase.handle.shipment.exception'
 
 
+class Amendment(metaclass=PoolMeta):
+    __name__ = 'purchase.amendment'
+
+    @classmethod
+    def _stock_moves(cls, line):
+        yield from super()._stock_moves(line)
+        for component in line.components:
+            for move in component.moves:
+                if move.state == 'draft':
+                    yield move
+
+
 class AmendmentLine(AmendmentLineMixin, metaclass=PoolMeta):
     __name__ = 'purchase.amendment.line'
diff -r 8d5e1d1e94f6 -r 2891dadc2165 sale.py
--- a/sale.py   Mon Mar 21 16:05:11 2022 +0100
+++ b/sale.py   Wed Apr 06 18:52:08 2022 +0200
@@ -144,5 +144,17 @@
     __name__ = 'sale.handle.shipment.exception'
 
 
+class Amendment(metaclass=PoolMeta):
+    __name__ = 'sale.amendment'
+
+    @classmethod
+    def _stock_moves(cls, line):
+        yield from super()._stock_moves(line)
+        for component in line.components:
+            for move in component.moves:
+                if move.state == 'draft':
+                    yield move
+
+
 class AmendmentLine(AmendmentLineMixin, metaclass=PoolMeta):
     __name__ = 'sale.amendment.line'

Reply via email to