diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index 429135b752f..f20e3da3dc5 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -730,6 +730,19 @@ class ProductTemplate(models.Model): self.ensure_one() if not parent_combination: return [] + + # Search for exclusions without attribute value. This means that the template is not + # compatible with the parent combination. If such an exclusion is found, it means that all + # attribute values are excluded. + if parent_combination: + exclusions = self.env['product.template.attribute.exclusion'].search([ + ('product_tmpl_id', '=', self.id), + ('value_ids', '=', False), + ('product_template_attribute_value_id', 'in', parent_combination.ids), + ], limit=1) + if exclusions: + return self.mapped('attribute_line_ids.product_template_value_ids').ids + return [ value_id for filter_line in parent_combination.mapped('exclude_for').filtered(