Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Events Sales

Entity: event.event

Compute Method: _compute_sale_price_total

View 19.0
Inputs Method Outputs
  • currency_id
  • company_id
+ """ Takes only confirmed the sale.order.lines related to this event and converts amounts
+         from the currency of the sale order to the currency of the event company.
+ 
+         To avoid extra overhead, we use conversion rates as of 'today'.
+         Meaning we have a number that can change over time, but using the conversion rates
+         at the time of the related sale.order would mean thousands of extra requests as we would
+         have to do one conversion per sale.order (and a sale.order is created every time
+         we sell a single event ticket). """
+ date_now = fields.Datetime.now()
+ event_subtotals = self.env['sale.order.line']._read_group(
+             [('event_id', 'in', self.ids), ('price_total', '!=', 0), ('state', '=', 'sale')],
+             ['event_id', 'currency_id'],
+             ['price_total:sum'],
+         )
+ event_subtotals_mapping = dict.fromkeys(self._origin, 0)
+ for event, currency, sum_price_subtotal in event_subtotals:
+             event_subtotals_mapping[event] += currency._convert(
+                 sum_price_subtotal,
+                 event.currency_id,
+                 event.company_id or self.env.company,
+                 date_now,
+             )
+ for event in self:
+             event.sale_price_total = event_subtotals_mapping.get(event._origin, 0)
  • sale_price_total

Back to entity