Skip to content

Commit

Permalink
Update bom_id, product_template_id on lines and order correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
FranzPoize committed Jun 6, 2024
1 parent cbcd929 commit 5ad4403
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions sale_mrp_bom_configurable/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class SaleOrderLine(models.Model):
allowed_product_id = fields.Char(
compute="_compute_allowed_product_id", store=True, precompute=True
)
should_not_filter_product = fields.Boolean(compute="_compute_should_filter_product")
should_not_filter_product = fields.Boolean(compute="_compute_should_not_filter_product")
should_filter_product = fields.Boolean()

should_compute_price = fields.Boolean(
compute="_compute_should_compute_price", store=True, precompute=True
Expand Down Expand Up @@ -73,16 +74,14 @@ def _get_default_product_id(self):
default=_get_default_product_id,
)

@api.depends("input_config_id", "product_id")
@api.depends("product_id", "order_id.bom_id")
def _compute_product_template_id(self):
for rec in self:
if (
self.env.context.get("configurable_quotation", False)
and not rec.is_static_product
):
rec.product_template_id = (
rec.order_id.input_config_id.bom_id.product_tmpl_id
)
rec.product_template_id = rec.order_id.bom_id.product_tmpl_id
else:
rec.product_template_id = rec.product_id.product_tmpl_id

Expand Down Expand Up @@ -114,11 +113,11 @@ def _compute_input_line_id(self):
else:
rec.input_line_id = False

@api.depends("input_line_id")
@api.depends("order_id.bom_id")
def _compute_bom_id(self):
for rec in self:
if not rec.is_static_product:
rec.bom_id = rec.input_line_id.bom_id
rec.bom_id = rec.order_id.bom_id
else:
rec.bom_id = False

Expand All @@ -132,7 +131,7 @@ def _compute_allowed_product_id(self):
rec.allowed_product_id = "-1"

@api.depends("input_config_id", "is_static_product")
def _compute_should_filter_product(self):
def _compute_should_not_filter_product(self):
for rec in self:
rec.should_not_filter_product = (not bool(rec.input_config_id)) or (
rec.is_static_product
Expand Down

0 comments on commit 5ad4403

Please sign in to comment.