You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
468 B

  1. from odoo import fields, models
  2. class PosOrderReport(models.Model):
  3. _inherit = 'report.pos.order'
  4. margin_total = fields.Float(string='Margin Total')
  5. margin_rate = fields.Float(string='Margin Rate', group_operator='avg')
  6. def _select(self):
  7. return super(PosOrderReport, self)._select() + """,
  8. SUM(l.margin) as margin_total,
  9. (SUM(l.margin / nullif(l.qty,0)) * 100 /
  10. SUM(nullif(l.purchase_price,0)))::decimal as margin_rate
  11. """