[FIX] website_sale_comparison: allow to compare no_variant attributes

closes odoo/odoo#159594

X-original-commit: 889fac0ea8452a5c778d98da81a91cbaff4116d4
Signed-off-by: Valentin Chevalier <vcr@odoo.com>
This commit is contained in:
Anna Janiszewska
2024-03-28 10:19:45 +00:00
committed by Valentin Chevalier
parent c357496609
commit ba1d081d78
2 changed files with 5 additions and 6 deletions
@@ -70,7 +70,7 @@ class ProductProduct(models.Model):
}]
}]
"""
attributes = self.product_tmpl_id.valid_product_template_attribute_line_ids._without_no_variant_attributes().attribute_id.sorted()
attributes = self.product_tmpl_id.valid_product_template_attribute_line_ids.attribute_id.sorted()
categories = OrderedDict([(cat, OrderedDict()) for cat in attributes.category_id.sorted()])
if any(not pa.category_id for pa in attributes):
# category_id is not required and the mapped does not return empty
@@ -78,7 +78,6 @@ class ProductProduct(models.Model):
for pa in attributes:
categories[pa.category_id][pa] = OrderedDict([(
product,
product.product_template_attribute_value_ids.filtered(lambda ptav: ptav.attribute_id == pa)
product.attribute_line_ids.filtered(lambda ptal: ptal.attribute_id == pa).value_ids
) for product in self])
return categories
@@ -161,7 +161,7 @@ class TestUi(odoo.tests.HttpCase):
tr_vintage = table.xpath('tbody/tr')[0]
text_vintage = etree.tostring(tr_vintage, encoding='unicode', method='text')
self.assertEqual(text_vintage.replace(' ', '').replace('\n', ''), "Vintage2018201720162015")
self.assertEqual(text_vintage.replace(' ', '').replace('\n', ''), "Vintage2018,2017,2016,20152018,2017,2016,20152018,2017,2016,20152018,2017,2016,2015")
tr_varieties = table.xpath('tbody/tr')[1]
text_varieties = etree.tostring(tr_varieties, encoding='unicode', method='text')
@@ -191,12 +191,12 @@ class TestUi(odoo.tests.HttpCase):
self.assertEqual(prep_categories, OrderedDict([
(category_varieties, OrderedDict([
(self.attribute_varieties, OrderedDict([
(self.template_margaux.product_variant_id, self.attribute_line_varieties.product_template_value_ids)
(self.template_margaux.product_variant_id, self.attribute_line_varieties.value_ids)
]))
])),
(category_vintage, OrderedDict([
(self.attribute_vintage, OrderedDict([
(self.template_margaux.product_variant_id, self.attribute_line_vintage.product_template_value_ids[0])
(self.template_margaux.product_variant_id, self.attribute_line_vintage.value_ids)
]))
])),
]))