From 57ae4edbf7647dd81b11063636260a46a8836281 Mon Sep 17 00:00:00 2001 From: Invitu Date: Wed, 14 Nov 2018 00:39:47 -1000 Subject: [PATCH] [IMP] Add pos margin in pos order report --- pos_margin/__init__.py | 1 + pos_margin/report/__init__.py | 2 ++ pos_margin/report/pos_order_report.py | 15 +++++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 pos_margin/report/__init__.py create mode 100644 pos_margin/report/pos_order_report.py 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 + """