-
company_id
-
id
-
currency_id
|
""" Compute the total amount (tax included) of paid/posted PoS orders linked to the event. """
totals = {event.id: 0.0 for event in self}
event_subtotals = self.env['pos.order.line']._read_group(
[('event_ticket_id.event_id', 'in', self.ids), ('order_id.state', 'in', ['paid', 'done'])],
['event_ticket_id.event_id', 'currency_id'],
['price_subtotal_incl:sum'],
)
for event, currency_id, sum_subtotal in event_subtotals:
company = event.company_id or self.env.company
totals[event.id] += event.currency_id._convert(sum_subtotal, currency_id, company)
for event in self:
event.pos_price_total = totals.get(event.id, 0.0)
|
|