Browse Source

[IMP] Add pos margin in pos order report

pull/326/head
Invitu 6 years ago
committed by Sylvain LE GAL
parent
commit
f469be4cb6
  1. 1
      pos_margin/__init__.py
  2. 2
      pos_margin/report/__init__.py
  3. 15
      pos_margin/report/pos_order_report.py

1
pos_margin/__init__.py

@ -1 +1,2 @@
from . import models from . import models
from . import report

2
pos_margin/report/__init__.py

@ -0,0 +1,2 @@
from . import pos_order_report

15
pos_margin/report/pos_order_report.py

@ -0,0 +1,15 @@
from odoo import fields, models
class PosOrderReport(models.Model):
_inherit = 'report.pos.order'
margin_total = fields.Float(string='Margin Total')
margin_rate = fields.Float(string='Margin Rate', group_operator='avg')
def _select(self):
return super(PosOrderReport, self)._select() + """,
SUM(l.margin) as margin_total,
(SUM(l.margin / nullif(l.qty,0)) * 100 /
SUM(nullif(l.purchase_price,0)))::decimal as margin_rate
"""
Loading…
Cancel
Save