Commit 0aed72a2 by François C.

Merge branch 'simple_product_list' into 'dev_cooperatic'

Add products simple list, to fit with product search in autocomplete list

See merge request !6
parents 4c3c6fbb 7c83c96a
......@@ -67,3 +67,37 @@ class LaCagetteProducts(models.Model):
@api.model
def get_barcodes(self, data):
return self.get_bc_with_minimun_data()
@api.model
def get_simple_list(self, data={}):
res = {}
try:
sql = """
SELECT
p.id,
p.product_tmpl_id as tpl_id,
(CASE WHEN translation.value IS NULL
THEN t.name
ELSE translation.value
END
) as display_name
FROM
product_product AS p
JOIN product_template AS t ON (p.product_tmpl_id = t.id)
LEFT JOIN ir_translation AS translation ON (t.id = translation.res_id AND translation.name = 'product.template,name')
WHERE p.id IS NOT NULL AND p.active = true
"""
if 'only_purchase_ok' in data:
sql += " AND purchase_ok = true"
self.env.cr.execute(sql)
req_res = self.env.cr.dictfetchall()
res['list'] = []
for p in req_res:
for attr in p.keys():
if p[attr] is None:
p[attr] = ''
res['list'].append(p)
except Exception as e:
res['error'] = str(e)
return res
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment