[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
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user