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.

26 lines
870 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright (C) 2016-Today: La Louve (<http://www.lalouve.net/>)
  3. # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from openerp import fields, models, api
  6. class PosSession(models.Model):
  7. _inherit = 'pos.session'
  8. @api.multi
  9. @api.depends('order_ids.lines.price_subtotal_incl')
  10. def _compute_orders(self):
  11. for session in self:
  12. session.order_qty = len(session.order_ids)
  13. session.total_amount = sum(
  14. session.mapped('order_ids.amount_total'))
  15. total_amount = fields.Monetary(
  16. compute='_compute_orders', string='Transactions Total', multi='orders',
  17. store=True)
  18. order_qty = fields.Integer(
  19. compute='_compute_orders', string='Orders Qty', multi='orders',
  20. store=True)