[IMP]: method product recommended

bzr revid: aja@tinyerp.com-20131220062711-2zgxcgp76k3ejjm0
This commit is contained in:
ajay javiya (OpenERP) 2013-12-20 11:57:11 +05:30
parent a4054b1407
commit e485c97794
1 changed files with 3 additions and 17 deletions

View File

@ -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