From a981196c8fe581e2de1450535f92c13952479f7b Mon Sep 17 00:00:00 2001 From: William Henrotin Date: Thu, 25 Apr 2019 08:46:04 +0000 Subject: [PATCH] [FIX] mrp: unlink workorder lines in post_inventory() Posting intermediate inventory in a manufacturing order using workorder need to delete all the remaining workorder lines. The post_inventory method create new raw moves for the remaining quantities then reserve those quantities. The reservation will create new workorder lines If the old workorder lines are not purged, the workorder will be asked to produced too much. closes odoo/odoo#32948 Signed-off-by: Simon Lejeune (sle) --- addons/mrp/models/mrp_production.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index e8bdc1677a5..12002b3b25a 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -823,6 +823,8 @@ class MrpProduction(models.Model): order._cal_price(moves_to_do) moves_to_finish = order.move_finished_ids.filtered(lambda x: x.state not in ('done', 'cancel')) moves_to_finish = moves_to_finish._action_done() + order.workorder_ids.mapped('raw_workorder_line_ids').unlink() + order.workorder_ids.mapped('finished_workorder_line_ids').unlink() order.action_assign() consume_move_lines = moves_to_do.mapped('move_line_ids') for moveline in moves_to_finish.mapped('move_line_ids'):