[FIX] website_sale: attribute selection unreversible

On a list of product, the attribue list (can be activated via the
customize menu) only contains the attribute pertaining to current
filtered product list.

Also, all the values of a the attribute are showed, even if choosing a
value will result in an empty product list.

It could lead to usability issue in some situations.

e.g

1) the current showed products number 2 with an attribute color,
2) we select "Red" which isn't a value these 2 products are declined in,
3) the current show products is now empty, but we can't un-select the
   "Red" color since "Color" is not an attribute of any of those 0
   product.

This commit solves this issue by displaying the currently selected
attributes if no product is displayed.

opw-653594
This commit is contained in:
Nicolas Lempereur
2015-11-05 10:32:02 +01:00
parent f376d7495b
commit 4e0821ae9a
+3 -1
View File
@@ -187,6 +187,7 @@ class website_sale(http.Controller):
attrib_list = request.httprequest.args.getlist('attrib')
attrib_values = [map(int, v.split("-")) for v in attrib_list if v]
attributes_ids = set([v[0] for v in attrib_values])
attrib_set = set([v[1] for v in attrib_values])
domain = self._get_search_domain(search, category, attrib_values)
@@ -231,7 +232,8 @@ class website_sale(http.Controller):
products = product_obj.browse(cr, uid, product_ids, context=context)
attributes_obj = request.registry['product.attribute']
attributes_ids = attributes_obj.search(cr, uid, [('attribute_line_ids.product_tmpl_id', 'in', product_ids)], context=context)
if product_ids:
attributes_ids = attributes_obj.search(cr, uid, [('attribute_line_ids.product_tmpl_id', 'in', product_ids)], context=context)
attributes = attributes_obj.browse(cr, uid, attributes_ids, context=context)
from_currency = pool['res.users'].browse(cr, uid, uid, context=context).company_id.currency_id