diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 79b04fa5ee6d125c2a9a3574c01422fa38e390f3..0de92eb5d444a4c4aa171e635d0bbaf9ea014fc6 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -149,8 +149,13 @@ class website_sale(http.Controller): context['pricelist'] = int(self.get_pricelist()) product_obj = pool.get('product.template') + url = "/shop" product_count = product_obj.search_count(cr, uid, domain, context=context) - pager = request.website.pager(url="/shop", total=product_count, page=page, step=PPG, scope=7, url_args=post) + if search: + post["search"] = search + if category: + url = "/shop/category/%s" % slug(category) + pager = request.website.pager(url=url, total=product_count, page=page, step=PPG, scope=7, url_args=post) product_ids = product_obj.search(cr, uid, domain, limit=PPG+10, offset=pager['offset'], order='website_published desc, website_sequence desc', context=context) products = product_obj.browse(cr, uid, product_ids, context=context) diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml index f4becb6ce45ae409237266df86764b67695dc6c6..6fe87097afbbbf47ed46b22fe4217620ced68ea5 100644 --- a/addons/website_sale/views/templates.xml +++ b/addons/website_sale/views/templates.xml @@ -29,18 +29,21 @@ </xpath> </template> <template id="search" name="Search hidden fields"> - <t t-if="attrib_values"> - <t t-foreach="attrib_values" t-as="a"> - <input type="hidden" name="attrib" t-att-value="'%s,%s' % (a[0], a[1])"/> + <form t-att-action="keep('/shop'+ ('/category/'+slug(category)) if category else '', search=0)" method="get" t-att-class="search_class"> + + <t t-if="attrib_values"> + <t t-foreach="attrib_values" t-as="a"> + <input type="hidden" name="attrib" t-att-value="'%s,%s' % (a[0], a[1])"/> + </t> </t> - </t> - <input t-if="category" type="hidden" name="category" t-att-value="int(category or 0)"/> - <div class="input-group"> - <input type="text" name="search" class="search-query form-control" placeholder="Search..." t-att-value="search"/> - <span class="input-group-btn"> - <a class="btn btn-default a-submit"><i class="fa fa-search"/></a> - </span> + <div class="input-group"> + <input type="text" name="search" class="search-query form-control" placeholder="Search..." t-att-value="search"/> + <span class="input-group-btn"> + <a class="btn btn-default a-submit"><i class="fa fa-search"/></a> + </span> </div> + + </form> </template> <template id="404"> @@ -125,9 +128,7 @@ <div class="container oe_website_sale"> <div class="products_pager"> <div class="row"> - <form t-att-action="keep('/shop',search=0)" method="get" class="pagination form-inline col-md-3"> - <t t-call="website_sale.search"/> - </form> + <t t-call="website_sale.search"><t t-set="search_class">pagination form-inline col-md-3</t></t> <t t-call="website.pager"/> </div> </div> @@ -353,9 +354,7 @@ </ol> </div> <div class="col-sm-3"> - <form t-att-action="keep(search=0)" method="get" class="pull-right"> - <t t-call="website_sale.search"/> - </form> + <t t-call="website_sale.search"><t t-set="search_class">pull-right</t></t> </div> <div class="col-sm-4" groups="base.group_sale_manager"> <t t-call="website.publish_management">