[IMP] website_sale : add sort by
Now you can sort products by lst_price, name, ... via the UI In some case the price list or b2b/b2c mode can altered the price and the sort on lst_price can be sometimes wrong. Eg: if price is displayed vat in (b2c), and mix rate of 6% and 21%, the sort will be done on the htva price.
This commit is contained in:
@@ -198,8 +198,7 @@ class WebsiteSale(http.Controller):
|
||||
|
||||
domain = self._get_search_domain(search, category, attrib_values)
|
||||
|
||||
keep = QueryURL('/shop', category=category and int(category), search=search, attrib=attrib_list)
|
||||
|
||||
keep = QueryURL('/shop', category=category and int(category), search=search, attrib=attrib_list, order=post.get('order'))
|
||||
pricelist_context = dict(request.env.context)
|
||||
if not pricelist_context.get('pricelist'):
|
||||
pricelist = request.website.get_current_pricelist()
|
||||
|
||||
@@ -339,6 +339,20 @@ odoo.define('website_sale.website_sale', function (require) {
|
||||
$(this).closest('tr').find('.js_quantity').val(0).trigger('change');
|
||||
});
|
||||
|
||||
if ($('.oe_website_sale .dropdown_sorty_by').length) {
|
||||
// this method allow to keep current get param from the action, with new search query
|
||||
$('.oe_website_sale .o_website_sale_search').on('submit', function (event) {
|
||||
var $this = $(this);
|
||||
if (!event.isDefaultPrevented() && !$this.is(".disabled")) {
|
||||
event.preventDefault();
|
||||
var oldurl = $this.attr('action');
|
||||
oldurl += (oldurl.indexOf("?")===-1) ? "?" : "";
|
||||
var search = $this.find('input.search-query');
|
||||
window.location = oldurl + '&' + search.attr('name') + '=' + encodeURIComponent(search.val());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($(".checkout_autoformat").length) {
|
||||
$(oe_website_sale).on('change', "select[name='country_id']", function () {
|
||||
clickwatch(function() {
|
||||
|
||||
@@ -161,7 +161,7 @@
|
||||
<div class="products_pager">
|
||||
<div class="row" style="width: 100%;">
|
||||
<t t-call="website_sale.search">
|
||||
<t t-set="search_class">pagination form-inline</t>
|
||||
<t t-set="search_class">pagination form-inline o_website_sale_search</t>
|
||||
</t>
|
||||
<t t-call="website_sale.pricelist_list" />
|
||||
<t t-call="website.pager" />
|
||||
@@ -210,6 +210,30 @@
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="sort" inherit_id="website_sale.products" active="True" customize_show="True" name="Show Sort by">
|
||||
<xpath expr="//div[@class='products_pager']/div/t[@t-call][last()]" position="after">
|
||||
<t t-set="website_sale_sortable" t-value="[
|
||||
('Price <i class=\'fa fa-arrow-up\' aria-hidden=\'true\'></i>', 'list_price desc'),
|
||||
('Price <i class=\'fa fa-arrow-down\' aria-hidden=\'true\'></i>', 'list_price asc'),
|
||||
('Name', 'name asc')
|
||||
]"/>
|
||||
<div class="dropdown btn-group dropdown_sorty_by">
|
||||
<a href="#" class="dropdown-toggle btn btn-default" data-toggle="dropdown">
|
||||
<span>Sort by</span>
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li t-foreach="website_sale_sortable" t-as="sortby">
|
||||
<a t-att-href="keep('/shop', order=sortby[1])">
|
||||
<span t-raw="sortby[0]"/>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
|
||||
<!-- Add to cart button-->
|
||||
<template id="categories_recursive" name="Category list">
|
||||
<li t-att-class="'active' if c.id == int(category or 0) else None">
|
||||
|
||||
Reference in New Issue
Block a user