Skip to content

Commit 0f6370d

Browse files
committed
[FIX] website_sale: ensure applied filters are preserved when sorting
Problem: When generating sorting URLs, the `post` dictionary only contains a single selected attribute. This is due to `request.params` only passing the first `attrib` parameter during dispatch, even though there can be multiple. Solution: Modify the `post` dictionary to store attributes as a list before passing it to the `_shop_get_query_url_kwargs` method. This ensures that all selected attributes are preserved and properly passed to the `keep` query parameters. Steps to reproduce: - Go to `/shop`. - Apply multiple attribute filters. - Change the sorting option. - Only the first selected attribute is applied in the filter. opw-4244895 closes odoo#187890 X-original-commit: 99c7bdd Signed-off-by: Valentin Chevalier <[email protected]> Signed-off-by: Walid Sahli (wasa) <[email protected]>
1 parent 35ef4b2 commit 0f6370d

File tree

1 file changed

+4
-3
lines changed
  • addons/website_sale/controllers

1 file changed

+4
-3
lines changed

addons/website_sale/controllers/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def _shop_lookup_products(self, attrib_set, options, post, search, website):
211211
return fuzzy_search_term, product_count, search_result
212212

213213
def _shop_get_query_url_kwargs(
214-
self, category, search, min_price, max_price, order=None, tags=None, **post
214+
self, category, search, min_price, max_price, order=None, tags=None, attribute_value=None, **post
215215
):
216216
return {
217217
'category': category,
@@ -220,6 +220,7 @@ def _shop_get_query_url_kwargs(
220220
'min_price': min_price,
221221
'max_price': max_price,
222222
'order': order,
223+
'attribute_value': attribute_value,
223224
}
224225

225226
def _get_additional_shop_values(self, values):
@@ -276,6 +277,8 @@ def shop(self, page=0, category=None, search='', min_price=0.0, max_price=0.0, p
276277
attrib_values = [[int(x) for x in v.split("-")] for v in attrib_list if v]
277278
attributes_ids = {v[0] for v in attrib_values}
278279
attrib_set = {v[1] for v in attrib_values}
280+
if attrib_list:
281+
post['attribute_value'] = attrib_list
279282

280283
filter_by_tags_enabled = website.is_view_active('website_sale.filter_products_tags')
281284
if filter_by_tags_enabled:
@@ -316,8 +319,6 @@ def shop(self, page=0, category=None, search='', min_price=0.0, max_price=0.0, p
316319
url = '/shop'
317320
if search:
318321
post['search'] = search
319-
if attrib_list:
320-
post['attribute_value'] = attrib_list
321322

322323
options = self._get_search_options(
323324
category=category,

0 commit comments

Comments
 (0)