diff --git a/pos_margin/__init__.py b/pos_margin/__init__.py index 0650744f..bf588bc8 100644 --- a/pos_margin/__init__.py +++ b/pos_margin/__init__.py @@ -1 +1,2 @@ from . import models +from . import report diff --git a/pos_margin/report/__init__.py b/pos_margin/report/__init__.py new file mode 100644 index 00000000..225fc1d2 --- /dev/null +++ b/pos_margin/report/__init__.py @@ -0,0 +1,2 @@ +from . import pos_order_report + diff --git a/pos_margin/report/pos_order_report.py b/pos_margin/report/pos_order_report.py new file mode 100644 index 00000000..ae826b40 --- /dev/null +++ b/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 + """