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"