From 07819834bb66942ff2085c3979261eaffccd2166 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Thu, 21 Nov 2013 14:05:29 +0100 Subject: [PATCH] [FIX] website_sale: filter controller and shop/?category=37 --> shop/category/37 bzr revid: chm@openerp.com-20131121130529-1zs3ioih5156ceit --- addons/website_sale/controllers/main.py | 17 +++++++++++------ addons/website_sale/views/website_sale.xml | 10 +++++----- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 2159304157c..80dc60e111f 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -289,10 +289,10 @@ class Ecommerce(http.Controller): filter[index.index(cat_id)].append( cat[2] ) post.pop(key) - return request.redirect("/shop/?filter=%s%s%s%s" % ( + return request.redirect("/shop/?filter=%s%s%s" % ( simplejson.dumps(filter), - post.get("search") and "&search=%s" % post.get("search") or "", - post.get("category") and "&category=%s" % post.get("category") or "" + post.get("search") and ("&search=%s" % post.get("search")) or "", + post.get("category") and ("&category=%s" % post.get("category")) or "" )) def attributes_to_ids(self, attributes): @@ -308,7 +308,12 @@ class Ecommerce(http.Controller): att = obj.read(request.cr, request.uid, att_ids, ["product_id"], context=request.context) return [r["product_id"][0] for r in att] - @website.route(['/shop/', '/shop/page//'], type='http', auth="public", multilang=True) + @website.route([ + '/shop/', + '/shop/page//', + '/shop/category//', + '/shop/category//page//' + ], type='http', auth="public", multilang=True) def category(self, category=0, filter="", page=0, **post): # TDE-NOTE: shouldn't we do somethign about product_template without variants ??? # TDE-NOTE: is there a reason to call a method category when the route is @@ -332,8 +337,8 @@ class Ecommerce(http.Controller): ('product_variant_ids.public_categ_id.name', 'ilike', "%%%s%%" % post.get("search"))] if category: - cat_id = int(category) - domain = [('product_variant_ids.public_categ_id.id', 'child_of', cat_id)] + domain + category_id = int(category) + domain = [('product_variant_ids.public_categ_id.id', 'child_of', category_id)] + domain if filter: filter = simplejson.loads(filter) diff --git a/addons/website_sale/views/website_sale.xml b/addons/website_sale/views/website_sale.xml index 6e1762b81cf..a029e326545 100644 --- a/addons/website_sale/views/website_sale.xml +++ b/addons/website_sale/views/website_sale.xml @@ -25,7 +25,7 @@