[FIX] website_sale_loyalty: fix possible crash during tests

This commit attempts to fix an undeterministic error, calling an
ensure_one method on an empty recordset.

closes odoo/odoo#99808

X-original-commit: 8e079bc0509f13794c61efeb1080c59baad65590
Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
This commit is contained in:
William Braeckman
2022-09-08 14:53:21 +02:00
parent 7b7aa99fc9
commit dc02b1cdba
@@ -30,8 +30,9 @@ class WebsiteSale(main.WebsiteSale):
def shop_payment(self, **post):
order = request.website.sale_get_order()
res = super(WebsiteSale, self).shop_payment(**post)
order._update_programs_and_rewards()
order._auto_apply_rewards()
if order:
order._update_programs_and_rewards()
order._auto_apply_rewards()
return res
@http.route(['/shop/cart'], type='http', auth="public", website=True)