diff --git a/stock_product_variant_mto/models/product_product.py b/stock_product_variant_mto/models/product_product.py index d3bdc05354bf..a2d3037934e4 100644 --- a/stock_product_variant_mto/models/product_product.py +++ b/stock_product_variant_mto/models/product_product.py @@ -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 ) @@ -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) diff --git a/stock_product_variant_mto/models/product_template.py b/stock_product_variant_mto/models/product_template.py index 4c2baebb9b72..e1680cc66629 100644 --- a/stock_product_variant_mto/models/product_template.py +++ b/stock_product_variant_mto/models/product_template.py @@ -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):