Add categories in pos_sale report

This commit is contained in:
Alexis de Lattre
2017-12-07 20:37:44 +01:00
parent 1faecd98f7
commit 81a4328531
2 changed files with 14 additions and 2 deletions

View File

@@ -16,6 +16,10 @@ class PosSaleReport(models.Model):
date = fields.Date(string='Order Date', readonly=True)
product_id = fields.Many2one(
'product.product', string='Product Variant', readonly=True)
product_categ_id = fields.Many2one(
'product.category', string='Product Category', readonly=True)
pos_categ_id = fields.Many2one(
'pos.category', string='Point of Sale Category', readonly=True)
product_tmpl_id = fields.Many2one(
'product.template', string='Product', readonly=True)
company_id = fields.Many2one(
@@ -28,6 +32,8 @@ class PosSaleReport(models.Model):
select = """SELECT min(sol.id)*-1 AS id,
so.date_order::date AS date,
sol.product_id AS product_id,
pt.categ_id AS product_categ_id,
pt.pos_categ_id AS pos_categ_id,
pp.product_tmpl_id AS product_tmpl_id,
so.company_id AS company_id,
'Sale Order' AS origin,
@@ -35,9 +41,10 @@ class PosSaleReport(models.Model):
FROM sale_order_line sol
LEFT JOIN sale_order so ON so.id = sol.order_id
LEFT JOIN product_product pp ON pp.id = sol.product_id
LEFT JOIN product_template pt ON pt.id = pp.product_tmpl_id
WHERE so.state NOT IN ('draft', 'sent', 'cancel')
GROUP BY so.date_order, sol.product_id, pp.product_tmpl_id,
so.company_id
so.company_id, pt.categ_id, pt.pos_categ_id
"""
return select
@@ -45,6 +52,8 @@ class PosSaleReport(models.Model):
select = """SELECT min(pol.id) AS id,
po.date_order::date AS date,
pol.product_id AS product_id,
pt.categ_id AS product_categ_id,
pt.pos_categ_id AS pos_categ_id,
pp.product_tmpl_id AS product_tmpl_id,
po.company_id AS company_id,
'Point of Sale' AS origin,
@@ -52,9 +61,10 @@ class PosSaleReport(models.Model):
FROM pos_order_line pol
LEFT JOIN pos_order po ON po.id = pol.order_id
LEFT JOIN product_product pp ON pp.id = pol.product_id
LEFT JOIN product_template pt ON pt.id = pp.product_tmpl_id
WHERE po.state IN ('paid', 'done', 'invoiced')
GROUP BY po.date_order, pol.product_id, pp.product_tmpl_id,
po.company_id
po.company_id, pt.categ_id, pt.pos_categ_id
"""
return select

View File

@@ -17,6 +17,8 @@
<filter name="date_groupby" string="Date" context="{'group_by': 'date'}"/>
<filter name="product_tmpl_groupby" string="Product" context="{'group_by': 'product_tmpl_id'}"/>
<filter name="product_groupby" string="Product Variants" context="{'group_by': 'product_id'}"/>
<filter name="product_categ_groupby" string="Product Categories" context="{'group_by': 'product_categ_id'}"/>
<filter name="pos_categ_groupby" string="Point of Sale Categories" context="{'group_by': 'pos_categ_id'}"/>
<filter name="company_groupby" string="Company" context="{'group_by': 'company_id'}"/>
<filter name="origin_groupby" string="Origin" context="{'group_by': 'origin'}"/>
</group>