Skip to content

Commit

Permalink
fixup! Refactor mto_route_product_variant
Browse files Browse the repository at this point in the history
  • Loading branch information
mmequignon committed Oct 11, 2024
1 parent d2dd13e commit d634638
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion stock_product_variant_mto/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ProductProduct(models.Model):
route_ids = fields.Many2many(
"stock.location.route",
compute="_compute_route_ids",
domain="[('product_selectable', '=', True)]",
store=False
)

Expand All @@ -34,7 +35,7 @@ def _compute_is_mto(self):
product.is_mto = False
continue
product.is_mto = mto_route in product.product_tmpl_id.route_ids

@api.depends("is_mto", "product_tmpl_id.route_ids")
def _compute_route_ids(self):
mto_route = self.env.ref("stock.route_warehouse0_mto", raise_if_not_found=False)
Expand Down
1 change: 1 addition & 0 deletions stock_product_variant_mto/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def write(self, values):
templates_mto_added = template_not_mto_before & templates_mto_after
templates_mto_removed = (self - template_not_mto_before) & (self - templates_mto_after)
(templates_mto_added | templates_mto_removed).product_variant_ids._compute_is_mto()
return res

@api.onchange("route_ids")
def onchange_route_ids(self):
Expand Down

0 comments on commit d634638

Please sign in to comment.