[IMP]: method product recommended
bzr revid: aja@tinyerp.com-20131220062711-2zgxcgp76k3ejjm0
This commit is contained in:
parent
a4054b1407
commit
e485c97794
|
@ -157,21 +157,7 @@ class sale_order(osv.osv):
|
||||||
def recommended_products(self, cr, uid, ids, context=None):
|
def recommended_products(self, cr, uid, ids, context=None):
|
||||||
order_line = self.browse(cr, uid, ids[0], context=context).order_line
|
order_line = self.browse(cr, uid, ids[0], context=context).order_line
|
||||||
product_pool = self.pool.get('product.product')
|
product_pool = self.pool.get('product.product')
|
||||||
product_ids = []
|
products = []
|
||||||
for line in order_line:
|
for line in order_line:
|
||||||
query = """
|
products += line.product_id.product_tmpl_id.recommended_products(context=context)
|
||||||
SELECT sol.product_id
|
return products
|
||||||
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)
|
|
||||||
|
|
Loading…
Reference in New Issue