diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index dd3a2cfdc94..50a8db02289 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -757,13 +757,13 @@ class website_sale(http.Controller): order = request.registry['sale.order'].browse(cr, SUPERUSER_ID, sale_order_id, context=context) assert order.id == request.session.get('sale_last_order_id') - if not tx or not order: + if not order or (order.amount_total and not tx): return request.redirect('/shop') - if not order.amount_total or tx.state in ['pending', 'done']: + if (not order.amount_total and not tx) or tx.state in ['pending', 'done']: # send by email email_act = sale_order_obj.action_quotation_send(cr, SUPERUSER_ID, [order.id], context=request.context) - elif tx.state == 'cancel': + elif tx and tx.state == 'cancel': # cancel the quotation sale_order_obj.action_cancel(cr, SUPERUSER_ID, [order.id], context=request.context)