From e485c977941f2676490158f4671c5f52d0df3cf7 Mon Sep 17 00:00:00 2001 From: "ajay javiya (OpenERP)" Date: Fri, 20 Dec 2013 11:57:11 +0530 Subject: [PATCH] [IMP]: method product recommended bzr revid: aja@tinyerp.com-20131220062711-2zgxcgp76k3ejjm0 --- addons/website_sale_quote/models/order.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/addons/website_sale_quote/models/order.py b/addons/website_sale_quote/models/order.py index cdbe6104e2f..84a6f137d49 100644 --- a/addons/website_sale_quote/models/order.py +++ b/addons/website_sale_quote/models/order.py @@ -157,21 +157,7 @@ class sale_order(osv.osv): def recommended_products(self, cr, uid, ids, context=None): order_line = self.browse(cr, uid, ids[0], context=context).order_line product_pool = self.pool.get('product.product') - product_ids = [] + products = [] for line in order_line: - query = """ - SELECT sol.product_id - FROM sale_order_line as my - LEFT JOIN sale_order_line as sol - ON sol.order_id = my.order_id - WHERE my.product_id in (%s) - AND sol.product_id not in (%s) - GROUP BY sol.product_id - ORDER BY COUNT(sol.order_id) DESC - LIMIT 10 - """ - cr.execute(query, (line.product_id.id, line.product_id.id)) - for p in cr.fetchall(): - product_ids.append(p[0]) - product_ids = product_pool.search(cr, uid, [("id", "in", product_ids)], limit=3) - return product_pool.browse(cr, uid, product_ids) + products += line.product_id.product_tmpl_id.recommended_products(context=context) + return products