Commit ce8930fb by François C.

Add lacagette_categories (Dev for Graoucoop shop custom)

parent 7f7eeed7
# -*- coding: utf-8 -*-
from . import models
\ No newline at end of file
# -*- coding: utf-8 -*-
{
'name': "La Cagette Categories",
'summary': """
Retrieve data from internal categories""",
'description': """
""",
'author': "fracolo",
'website': "https://lacagette-coop.fr",
# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml
# for the full list
'category': 'Product',
'version': '0.0.1',
# any module necessary for this one to work correctly
'depends': ['base', 'product'],
# always loaded
'data': [
],
'installable': True,
}
# -*- coding: utf-8 -*-
from . import categories
# -*- coding: utf-8 -*-
from openerp import _, api, models, fields
class LaCagetteCategories(models.Model):
_name = "lacagette.categories"
@api.model
def get_all_with_products_count(self):
res = {}
try:
sql = """
SELECT
categ_id, count(*) as nb
FROM product_template
WHERE
active=true AND sale_ok=true
GROUP BY categ_id;
"""
self.env.cr.execute(sql)
res['list'] = {}
req_res = self.env.cr.dictfetchall()
for u in req_res:
for attr in u.keys():
if u[attr] is None:
u[attr] = ''
res['list'][str(u['categ_id'])] = u['nb']
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