From f4bc8143b77aaaeefc0b970db50fa3bd4170479e Mon Sep 17 00:00:00 2001 From: Mmequignon Date: Tue, 23 Jan 2024 16:45:37 +0100 Subject: [PATCH] fixup! Refactor mto_route_product_variant --- stock_product_variant_mto/models/product_product.py | 2 +- stock_product_variant_mto/models/product_template.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/stock_product_variant_mto/models/product_product.py b/stock_product_variant_mto/models/product_product.py index d3bdc05354bf..e190f6282bff 100644 --- a/stock_product_variant_mto/models/product_product.py +++ b/stock_product_variant_mto/models/product_product.py @@ -34,7 +34,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):