From b5b4979dd107aeac606b4e6b00cdbc411f639b16 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 10 Feb 2017 11:31:13 +0100 Subject: [PATCH] [FIX] mrp: cancel raw materials procurements To reproduce: - Create a product A with the routes Manufacturing & Make to Order - Create a product B with the routes Make to Order & a custom one "Move from Shelf 1" (see screenshot for the configuration detail) - Create a BoM for product A which contains the component product B - Sell product A in a SO and confirm it - It creates a delivery order for product A, a manufacturing order for Product A & B and an internal transfer for product B - The move for product B from WH/Stock/Shelf 1 to WH/Stock is indeed linked to the move for product B from WH/Stock to Virtual Location/Production - Cancel the sales order - All stock moves are cancelled, except the one related to the internal transfer (WH/Stock/Shelf 1 to WH/Stock) When the manufacturing order is canceled, raw material as well as finished moves are canceled. All procurements with finished moves as "Destination Move" are canceled as well. However, in this use case, a procurement has been created for a raw material. The solution is to cancel procurements for raw materials as well, so it cancels the internal transfer. opw-706100 --- addons/mrp/models/mrp_production.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index c19cd67771d..b413e800b52 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -467,10 +467,10 @@ class MrpProduction(models.Model): production.workorder_ids.filtered(lambda x: x.state != 'cancel').action_cancel() finish_moves = production.move_finished_ids.filtered(lambda x: x.state not in ('done', 'cancel')) - production.move_raw_ids.filtered(lambda x: x.state not in ('done', 'cancel')).action_cancel() - finish_moves.action_cancel() + raw_moves = production.move_raw_ids.filtered(lambda x: x.state not in ('done', 'cancel')) + (finish_moves | raw_moves).action_cancel() - procurements = ProcurementOrder.search([('move_dest_id', 'in', finish_moves.ids)]) + procurements = ProcurementOrder.search([('move_dest_id', 'in', (finish_moves | raw_moves).ids)]) if procurements: procurements.cancel()