From 634bdbfa3a316fcaa9323f97bb59f198cd771b27 Mon Sep 17 00:00:00 2001
From: William Henrotin <whe@odoo.com>
Date: Mon, 5 Aug 2019 11:22:00 +0000
Subject: [PATCH] [FIX] mrp: blocks default product on bom line

The action called from the product's bom stat button (mrp.product_open_bom)
fill the key 'default_product_id'. This allows, creating a bom from the list view,
to prefilled the product.

This context key will also fill each new bom line as the technical field is
called product_id too.

This commit overrides default_product_id to False for the bom line One2many
in the bom form view in order to only prefill the finished product and not
the components.

Task : 2045485

closes odoo/odoo#35444

Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
---
 addons/mrp/views/mrp_bom_views.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/addons/mrp/views/mrp_bom_views.xml b/addons/mrp/views/mrp_bom_views.xml
index 6a66e7f82e69..47cb73a7d9ee 100644
--- a/addons/mrp/views/mrp_bom_views.xml
+++ b/addons/mrp/views/mrp_bom_views.xml
@@ -51,7 +51,7 @@
                     </group>
                     <notebook>
                         <page string="Components">
-                            <field name="bom_line_ids" widget="one2many" context="{'default_parent_product_tmpl_id': product_tmpl_id}">
+                            <field name="bom_line_ids" widget="one2many" context="{'default_parent_product_tmpl_id': product_tmpl_id, 'default_product_id': False}">
                                 <tree string="Components" editable="bottom">
                                     <field name="sequence" widget="handle"/>
                                     <field name="product_id" context="{'default_type': 'product'}"/>
-- 
GitLab