Commit 7c83c96a by François C.

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

parent 57044e23
...@@ -67,3 +67,37 @@ class LaCagetteProducts(models.Model): ...@@ -67,3 +67,37 @@ class LaCagetteProducts(models.Model):
@api.model @api.model
def get_barcodes(self, data): def get_barcodes(self, data):
return self.get_bc_with_minimun_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