From 404eb2f00f2f35d968704fe340a96efa8ae4df83 Mon Sep 17 00:00:00 2001 From: William Henrotin Date: Wed, 29 Jul 2020 10:13:34 +0000 Subject: [PATCH] [FIX] mrp: do not erase move raw at onchange without bom With this commit, the move raw refresher onchange is bypassed in case of empty BoM. As the manufacturing user can adds some components on the fly to create a non manufactured product, changing the quantity to produce or the unit of measur will erase all the move raw and recreate them from the BoM lines. As no boms are set, the components are just deleted. Task : 2278147 --- 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 c35b03869cf..ae6aaa5b306 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -604,6 +604,8 @@ class MrpProduction(models.Model): @api.onchange('bom_id', 'product_id', 'product_qty', 'product_uom_id') def _onchange_move_raw(self): + if not self.bom_id and not self._origin.product_id: + return # Clear move raws if we are changing the product. In case of creation (self._origin is empty), # we need to avoid keeping incorrect lines, so clearing is necessary too. if self.product_id != self._origin.product_id: