From f7e0787ae409483fd9dcd3c10e4cb114c2c0f756 Mon Sep 17 00:00:00 2001 From: Swapnesh Shah Date: Sun, 2 May 2021 19:52:53 +0000 Subject: [PATCH] [FIX] mrp: set default product on unbuild order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, Creating Unbuild order using Unbuild Button was resetting Bom as it was calling `_onchange_product_id` after setting `mo_id` which was resetting Bom on Unbuild order. To Fix Issue, We setting `default_product_id` so It would not reset `bom_id` when `_onchange_product_id` is called. Fixes: #70216 Odoo Ticket: 2521788 closes odoo/odoo#70304 X-original-commit: 4de0ae434d1adc97fc1077b8d0f23c7e800ec161 Signed-off-by: Rémy Voet --- addons/mrp/models/mrp_production.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index eed08659bf6..9ab12705f53 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -1622,7 +1622,8 @@ class MrpProduction(models.Model): 'res_model': 'mrp.unbuild', 'view_id': self.env.ref('mrp.mrp_unbuild_form_view_simplified').id, 'type': 'ir.actions.act_window', - 'context': {'default_mo_id': self.id, + 'context': {'default_product_id': self.product_id.id, + 'default_mo_id': self.id, 'default_company_id': self.company_id.id, 'default_location_id': self.location_dest_id.id, 'default_location_dest_id': self.location_src_id.id,