[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
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user