[FIX] website_sale: allow validation of free orders (amount = 0) without payment...
authorChristophe Simonis <chs@openerp.com>
Fri, 28 Feb 2014 12:34:14 +0000 (13:34 +0100)
committerChristophe Simonis <chs@openerp.com>
Fri, 28 Feb 2014 12:34:14 +0000 (13:34 +0100)
bzr revid: chs@openerp.com-20140228123414-4chmuemyi72rpwgf

addons/website_sale/controllers/main.py

index 8f669c1..8dacda0 100644 (file)
@@ -713,7 +713,6 @@ class Ecommerce(http.Controller):
          - UDPATE ME
         """
         cr, uid, context = request.cr, request.uid, request.context
-        email_act = None
         sale_order_obj = request.registry['sale.order']
 
         if transaction_id is None:
@@ -727,17 +726,19 @@ class Ecommerce(http.Controller):
             order = request.registry['sale.order'].browse(cr, SUPERUSER_ID, sale_order_id, context=context)
             assert order.website_session_id == request.httprequest.session['website_session_id']
 
-        if not tx or not order:
+        if not order:
             return request.redirect('/shop/')
+        elif order.amount_total and not tx:
+            return request.redirect('/shop/mycart')
 
         if not order.amount_total or tx.state == 'done':
             # confirm the quotation
             sale_order_obj.action_button_confirm(cr, SUPERUSER_ID, [order.id], context=request.context)
             # send by email
-            email_act = sale_order_obj.action_quotation_send(cr, SUPERUSER_ID, [order.id], context=request.context)
+            sale_order_obj.action_quotation_send(cr, SUPERUSER_ID, [order.id], context=request.context)
         elif tx.state == 'pending':
             # send by email
-            email_act = sale_order_obj.action_quotation_send(cr, SUPERUSER_ID, [order.id], context=request.context)
+            sale_order_obj.action_quotation_send(cr, SUPERUSER_ID, [order.id], context=request.context)
         elif tx.state == 'cancel':
             # cancel the quotation
             sale_order_obj.action_cancel(cr, SUPERUSER_ID, [order.id], context=request.context)