[FIX] mrp_bom_attribute_match: avoid recursion in BOM.

This commit is contained in:
Ilyas
2023-06-02 11:26:24 +02:00
parent f2092617ca
commit 2016a06198
3 changed files with 17 additions and 2 deletions

View File

@@ -5,6 +5,7 @@
"author": "Ilyas, Ooops, Odoo Community Association (OCA)",
"summary": "Dynamic BOM component based on product attribute",
"depends": ["mrp"],
"maintainers": ["ilyasProgrammer", "ivantodorovich"],
"license": "AGPL-3",
"website": "https://github.com/OCA/manufacture",
"data": [

View File

@@ -15,7 +15,9 @@ class MrpBomLine(models.Model):
"product.product", help="Technical field to store previous value of product_id"
)
component_template_id = fields.Many2one(
"product.template", "Component (product template)"
"product.template",
"Component (product template)",
domain="[('id', '!=', parent_product_tmpl_id)]",
)
match_on_attribute_ids = fields.Many2many(
"product.attribute",
@@ -29,6 +31,18 @@ class MrpBomLine(models.Model):
compute="_compute_product_uom_category_id",
)
@api.constrains("component_template_id")
def _check_component_template_recursion(self):
for line in self:
if line.component_template_id == line.parent_product_tmpl_id:
raise ValidationError(
_(
"Component template must be different from BOM "
"product template. Please check BOM: %s BOM Line: %s"
)
% (line, line.bom_id)
)
@api.depends("product_id", "component_template_id")
def _compute_product_uom_category_id(self):
"""Compute the product_uom_category_id field.

View File

@@ -1,6 +1,6 @@
* Ooops404 <https://ooops404.com>
* Ilyas
* Ilyas <irazor147@gmail.com>
* `Camptocamp <https://www.camptocamp.com>`_