[FIX] website_sale: visible attributes wrongly computed for some variants
On one hand, when a product attribute is shared by several products, some may use different subsets of its possible values. On the other hand, when less than 2 values are enabled for a given attribute on a product, no choice is displayed for that attribute on the shop page, as there is none to be made. The way those "visible attributes" were computed in get_attribute_values() was wrong: when counting the number of values it used the whole range of possible values for this attribute (cross-product), not just those enabled for that product. This lead to inconsistencies vs the website_sale.variants template, and products using a single value out of a larger range of values were constantly marked as "Not available" in the shop.
This commit is contained in:
parent
6451a553c0
commit
c18a7eb82a
|
@ -122,14 +122,17 @@ class website_sale(http.Controller):
|
|||
cr, uid, context, pool = request.cr, request.uid, request.context, request.registry
|
||||
currency_obj = pool['res.currency']
|
||||
attribute_value_ids = []
|
||||
visible_attrs = set(l.attribute_id.id
|
||||
for l in product.attribute_line_ids
|
||||
if len(l.value_ids) > 1)
|
||||
if request.website.pricelist_id.id != context['pricelist']:
|
||||
website_currency_id = request.website.currency_id.id
|
||||
currency_id = self.get_pricelist().currency_id.id
|
||||
for p in product.product_variant_ids:
|
||||
price = currency_obj.compute(cr, uid, website_currency_id, currency_id, p.lst_price)
|
||||
attribute_value_ids.append([p.id, [v.id for v in p.attribute_value_ids if len(v.attribute_id.value_ids) > 1], p.price, price])
|
||||
attribute_value_ids.append([p.id, [v.id for v in p.attribute_value_ids if v.attribute_id.id in visible_attrs], p.price, price])
|
||||
else:
|
||||
attribute_value_ids = [[p.id, [v.id for v in p.attribute_value_ids if len(v.attribute_id.value_ids) > 1], p.price, p.lst_price]
|
||||
attribute_value_ids = [[p.id, [v.id for v in p.attribute_value_ids if v.attribute_id.id in visible_attrs], p.price, p.lst_price]
|
||||
for p in product.product_variant_ids]
|
||||
|
||||
return attribute_value_ids
|
||||
|
|
Loading…
Reference in New Issue