[FIX] website_sale: fix error in tracking_last_order which was using the field is_del...
authorJeremy Kersten <jke@odoo.com>
Thu, 24 Jul 2014 09:07:46 +0000 (11:07 +0200)
committerJeremy Kersten <jke@odoo.com>
Thu, 24 Jul 2014 09:07:46 +0000 (11:07 +0200)
addons/website_sale/controllers/main.py
addons/website_sale_delivery/controllers/main.py

index b9738e4..4b496c0 100644 (file)
@@ -765,9 +765,22 @@ class website_sale(http.Controller):
         product = product_obj.browse(request.cr, request.uid, id, context=request.context)
         return product.write({'website_size_x': x, 'website_size_y': y})
 
+    def order_lines_2_google_api(self, order_lines):
+        """ Transforms a list of order lines into a dict for google analytics """
+        ret = []
+        for line in order_lines:
+            ret.append({
+                'id': line.order_id and line.order_id.id,
+                'name': line.product_id.categ_id and line.product_id.categ_id.name or '-',
+                'sku': line.product_id.id,
+                'quantity': line.product_uom_qty,
+                'price': line.price_unit,
+            })
+        return ret
+
     @http.route(['/shop/tracking_last_order'], type='json', auth="public")
     def tracking_cart(self, **post):
-        """ return JS code for google analytics"""
+        """ return data about order in JSON needed for google analytics"""
         cr, uid, context = request.cr, request.uid, request.context
         ret = {}
         sale_order_id = request.session.get('sale_last_order_id')
@@ -779,16 +792,7 @@ class website_sale(http.Controller):
                 'revenue': order.amount_total,
                 'currency': order.currency_id.name
             }
-            ret['lines'] = []
-            for line in order.order_line:
-                if not line.is_delivery:
-                    ret['lines'].append({
-                        'id': line.order_id and line.order_id.id,
-                        'name': line.product_id.categ_id and line.product_id.categ_id.name or '-',
-                        'sku': line.product_id.id,
-                        'quantity': line.product_uom_qty,
-                        'price': line.price_unit,
-                    })
+            ret['lines'] = self.order_lines_2_google_api(order.order_line)
         return ret
 
 # vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
index 93c6aa2..15bc881 100644 (file)
@@ -1,10 +1,10 @@
 # -*- coding: utf-8 -*-
 import openerp
 from openerp import http
-from openerp import SUPERUSER_ID
 from openerp.http import request
 import openerp.addons.website_sale.controllers.main
 
+
 class website_sale(openerp.addons.website_sale.controllers.main.website_sale):
 
     @http.route(['/shop/payment'], type='http', auth="public", website=True)
@@ -21,3 +21,8 @@ class website_sale(openerp.addons.website_sale.controllers.main.website_sale):
 
         res = super(website_sale, self).payment(**post)
         return res
+
+    def order_lines_2_google_api(self, order_lines):
+        """ Transforms a list of order lines into a dict for google analytics """
+        order_lines_not_delivery = [line for line in order_lines if not line.is_delivery]
+        return super(website_sale, self).order_lines_2_google_api(order_lines_not_delivery)