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.

39 lines
1.2 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Copyright (C) 2016-Today La Louve (<http://www.lalouve.net/>)
  5. #
  6. # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
  7. #
  8. # The licence is in the file __openerp__.py
  9. #
  10. ##############################################################################
  11. from openerp import fields, models, api
  12. class PosSession(models.Model):
  13. _inherit = 'pos.session'
  14. @api.multi
  15. @api.depends('statement_ids.balance_end')
  16. def _compute_total_amount(self):
  17. for session in self:
  18. total_amount = 0
  19. for statement in session.statement_ids:
  20. total_amount += statement.balance_end
  21. session.total_amount = total_amount
  22. @api.multi
  23. @api.depends('order_ids')
  24. def _compute_order_qty(self):
  25. for session in self:
  26. session.order_qty = len(session.order_ids)
  27. total_amount = fields.Monetary(
  28. compute='_compute_total_amount', string='Transactions Total',
  29. store=True)
  30. order_qty = fields.Integer(
  31. compute='_compute_order_qty', string='Orders Qty',
  32. store=True)