[FIX] mrp: dynamic attribute

- In inventory app, create an attribute that is dynamic
- Create a product with a variant with the dynamic attribute
- Create a bom for the product with some specific component for that variant
- Open structure and cost

A crash occurs.

In this case, the object is a `product.template`, so a condition
product-specific shouldn't be checked.

The template is set at:

https://github.com/odoo/odoo/blob/3588487ab4ef867f7fb981a395deaf298eb4a4e4/addons/mrp/report/mrp_report_bom_structure.py#L107

opw-2198976

closes odoo/odoo#47769

X-original-commit: 3c476dee5d3a0cc0fde0f9c6620507a07929e4fc
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2020-03-17 09:24:01 +00:00
parent d4a83593c6
commit 17e12603a2
+2
View File
@@ -355,6 +355,8 @@ class MrpBomLine(models.Model):
them has to be found on the variant.
"""
self.ensure_one()
if product._name == 'product.template':
return False
if self.bom_product_template_attribute_value_ids:
for ptal, iter_ptav in groupby(self.bom_product_template_attribute_value_ids.sorted('attribute_line_id'), lambda ptav: ptav.attribute_line_id):
if not any([ptav in product.product_template_attribute_value_ids for ptav in iter_ptav]):