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