From 5808fc898ecbbf23d93693f7d957a6700de144c6 Mon Sep 17 00:00:00 2001
From: niyasraphy <niyasraphyk@gmail.com>
Date: Fri, 19 May 2023 19:34:24 +0000
Subject: [PATCH] [FIX] mrp: clear product variant onchanging product in bom

before this commit, on changing the product from bom is
not clearing the product variant field, if the product
variant feature is not activated in the database.

* activate the product variant in the db
* create a product and variants
* open bill of material, and set the created
product as product and set any variant in product
variant field
* now go to settings and disable product variant feature
* come back to same bom and change the product
* the product variant field will still have the other
product

onchange_product_tmpl_id is written to clear the
product variant field value, but as the product
variant field has group the onchange value is
not getting updated.

after this commit, on changing the product the product
variant field will get cleared even if the product
variant feature is not activated.

closes odoo/odoo#121859

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
---
 addons/mrp/views/mrp_bom_views.xml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/addons/mrp/views/mrp_bom_views.xml b/addons/mrp/views/mrp_bom_views.xml
index feb02ef4a011..7db5e6531ef1 100644
--- a/addons/mrp/views/mrp_bom_views.xml
+++ b/addons/mrp/views/mrp_bom_views.xml
@@ -56,6 +56,7 @@
                             <field name="product_uom_category_id" invisible="1"/>
                             <field name="allow_operation_dependencies" invisible="1"/>
                             <field name="product_id" groups="product.group_product_variant" context="{'default_detailed_type': 'product'}"/>
+                            <field name="product_id" groups="!product.group_product_variant" invisible="1"/>
                             <label for="product_qty" string="Quantity"/>
                             <div class="o_row">
                                 <field name="product_qty"/>
-- 
GitLab