Skip to content
Snippets Groups Projects
Commit 35221a32 authored by Nicolas Martinelli's avatar Nicolas Martinelli
Browse files

[FIX] product: exclude without attribute values

With the demo data:
- Go to Sale > Products > Products, search for 'Customizable Desk'
- Click on 'Configure Variants'
- For variant 'Legs: Steel', remove the attribute values for the
  'Conference Chair'
- Create a SO, add a line with 'Configure Product'
- Select the 'Customizable Desk' with 'Legs: Steel', add

The 'Conference Chair' is displayed in the 'Available Options', while it
shouldn't.

The methods `_get_own_attribute_exclusions` and
`_get_parent_attribute_exclusions` compute the exclusions based on the
attribute values. Since there is no values in our case, the exclusion is
not taken into account.

We add a specific case to search for exclusions without values.

opw-1945460
parent d2a65549
No related branches found
No related tags found
No related merge requests found
......@@ -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(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment