[FIX] website_sale: restore possibility to remove promo code pricelist
Since 5c9cea4ee7, it was not possible to remove an applied promo code
pricelist by adding an empty promo code on checkout (eg removing the one shown
in the promo code input).
Indeed, when sending an empty promo code, the `search()` done in the controller
would not find any pricelist as promo would be en empty string. For the rest,
check code on mentionned commit.
See `sale_get_order()` method docstring about `code` param: "If empty, it's a
special case to reset the pricelist with the first available else the default.".
Fixes #34633
This commit is contained in:
committed by
Jeremy Kersten
parent
160b7c87bb
commit
36fdb2ff49
@@ -332,9 +332,11 @@ class WebsiteSale(http.Controller):
|
||||
@http.route(['/shop/pricelist'], type='http', auth="public", website=True)
|
||||
def pricelist(self, promo, **post):
|
||||
redirect = post.get('r', '/shop/cart')
|
||||
pricelist = request.env['product.pricelist'].sudo().search([('code', '=', promo)], limit=1)
|
||||
if not pricelist or (pricelist and not request.website.is_pricelist_available(pricelist.id)):
|
||||
return request.redirect("%s?code_not_available=1" % redirect)
|
||||
# empty promo code is used to reset/remove pricelist (see `sale_get_order()`)
|
||||
if promo:
|
||||
pricelist = request.env['product.pricelist'].sudo().search([('code', '=', promo)], limit=1)
|
||||
if (not pricelist or (pricelist and not request.website.is_pricelist_available(pricelist.id))):
|
||||
return request.redirect("%s?code_not_available=1" % redirect)
|
||||
|
||||
request.website.sale_get_order(code=promo)
|
||||
return request.redirect(redirect)
|
||||
|
||||
Reference in New Issue
Block a user