summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ledoux <dle@odoo.com>2016-09-14 12:44:54 +0200
committerDenis Ledoux <dle@odoo.com>2016-09-14 12:59:15 +0200
commit01c68bc2a4bed263dd5ff298825e1dc25bcc2fe3 (patch)
tree2ad6d95206ce8fb822fc88c4516453600545d17d
parent19b4f5efe4ee69f0fcd73ebe80f6347b30681354 (diff)
[FIX] website_sale: fix variants availability on website product page
This is an oversight during the conversion to the new API in the revision 788c1334e2cbe26fa26d4c6d4974dc413dbff608 In the above revision, ``` visible_attrs = set(l.attribute_id.id for l in product.attribute_line_ids if len(l.value_ids) > 1) ``` has been converted to ``` visible_attrs_ids = product.mapped('attribute_line_ids.attribute_id').filtered(lambda attr: len(attr.value_ids) > 1).ids ``` which leads to a change of behavior: Before the conversion, the filter is applied on the attribute line `value_ids` field: `if len(l.value_ids) > 1`, `l` being one item of `attribute_line_ids` After the converison, the filter is applied on the attribute line `attribute_id.value_ids` field `filtered(lambda attr: len(attr.value_ids) > 1)`, `attr` being the `attribute_id` field of one item of `attribute_line_ids` Therefore breaking the availability of the product variants in the products pages of the ecommerce. e.g. Attribute color, values red, blue, white, black The product "Tshirt" is defined with as possible colors values red only. Before, the filter would not return the attribute `color` for this product, as the product has only one possible value for this attribute After, the filter would return the attribute `color`, since this attribute as more than one possible values (but, not for this product) opw-688470
-rw-r--r--addons/website_sale/controllers/main.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py
index bc367eb917b..e6124ca0291 100644
--- a/addons/website_sale/controllers/main.py
+++ b/addons/website_sale/controllers/main.py
@@ -110,7 +110,7 @@ class WebsiteSale(http.Controller):
(variant id, [visible attribute ids], variant price, variant sale price)
"""
# product attributes with at least two choices
- visible_attrs_ids = product.mapped('attribute_line_ids.attribute_id').filtered(lambda attr: len(attr.value_ids) > 1).ids
+ visible_attrs_ids = product.attribute_line_ids.filtered(lambda l: len(l.value_ids) > 1).mapped('attribute_id').ids
to_currency = request.website.get_current_pricelist().currency_id
attribute_value_ids = []
for variant in product.product_variant_ids: