From e7c97127f23cce2f79e42afdb50595e4a5b5ea23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 6 Apr 2022 18:52:08 +0200 Subject: [PATCH] Delete stock moves from components when applying amendment issue11355 review386301002 (grafted from b6a221e5d224b438d1576f80ef9e201e20193321) --HG-- branch : 6.0 --- sale.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sale.py b/sale.py index 4ef2641e16..0712c66385 100644 --- a/sale.py +++ b/sale.py @@ -152,9 +152,7 @@ class Amendment(Workflow, ModelSQL, ModelView): 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 @@ class Amendment(Workflow, ModelSQL, ModelView): 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"