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.

24 lines
798 B

  1. # Copyright (C) 2017 - Today: GRAP (http://www.grap.coop)
  2. # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo import api, fields, models
  5. import odoo.addons.decimal_precision as dp
  6. class PosOrder(models.Model):
  7. _inherit = 'pos.order'
  8. # Columns Section
  9. margin = fields.Float(
  10. 'Margin', compute='_compute_margin', store=True,
  11. digits=dp.get_precision('Product Price'),
  12. help="It gives profitability by calculating the difference between"
  13. " the Unit Price and the cost price.")
  14. # Compute Section
  15. @api.multi
  16. @api.depends('lines.margin')
  17. def _compute_margin(self):
  18. for order in self:
  19. order.margin = sum(order.mapped('lines.margin'))