From 4e0821ae9a6a8389032ef52e3f9f7bdf081cc7ff Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 4 Nov 2015 17:50:57 +0100 Subject: [PATCH] [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 --- addons/website_sale/controllers/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 680be96df9d..256857fbfce 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -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