summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRomain Derie <rde@odoo.com>2018-10-12 12:51:32 +0000
committerRomain Derie <rde@odoo.com>2018-10-12 12:57:03 +0000
commit53f72dcab154376190d71cd21f3d5d75e5960776 (patch)
tree570a24ee77d4dde842bdb71319b6fe4c67b0b8ee
parent9649920987115f9f71dc871b099cd571add6507a (diff)
[FIX] website_sale: /shop 500 error if category is not model converter
The /shop route can take a `category` argument (a model converter). `/shop/category/<model("product.public.category"[..]):category>` But if that `category` argument is passed through URL query string (?category=9), it will raise an error when doing `category.can_access_from_current_website()` as it is an integer since it did not went through the model converter Note: Among probably others, that type of route is used when changing product order on shop Closes #27490, closes #27724
-rw-r--r--addons/website_sale/controllers/main.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py
index 24be13bf049..c157b585669 100644
--- a/addons/website_sale/controllers/main.py
+++ b/addons/website_sale/controllers/main.py
@@ -189,8 +189,11 @@ class WebsiteSale(ProductConfiguratorController):
'''/shop/category/<model("product.public.category", "[('website_id', 'in', (False, current_website_id))]"):category>/page/<int:page>'''
], type='http', auth="public", website=True)
def shop(self, page=0, category=None, search='', ppg=False, **post):
- if category and not category.can_access_from_current_website():
- raise NotFound()
+ if category:
+ category = request.env['product.public.category'].search([('id', '=', int(category))], limit=1)
+ if not category or not category.can_access_from_current_website():
+ raise NotFound()
+
if ppg:
try:
ppg = int(ppg)
@@ -200,11 +203,6 @@ class WebsiteSale(ProductConfiguratorController):
else:
ppg = PPG
- if category:
- category = request.env['product.public.category'].search([('id', '=', int(category))], limit=1)
- if not category:
- raise NotFound()
-
attrib_list = request.httprequest.args.getlist('attrib')
attrib_values = [[int(x) for x in v.split("-")] for v in attrib_list if v]
attributes_ids = {v[0] for v in attrib_values}