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

Module: Base

Entity: res.currency

Compute Method: _compute_current_rate

View 19.0
Inputs Method Outputs
  • id
  • rate
  • name
- date = self.env.context.get('date') or fields.Date.context_today(self)
- company = self.env['res.company'].browse(self.env.context.get('company_id')) or self.env.company
- to_currency = self.browse(self.env.context.get('to_currency')) or company.currency_id
- currency_rates = (self + to_currency)._get_rates(self.env.company, date)
- for currency in self:
-             currency.rate = (currency_rates.get(currency.id) or 1.0) / currency_rates.get(to_currency.id)
-             currency.inverse_rate = 1 / currency.rate
-             if currency != company.currency_id:
-                 currency.rate_string = '1 %s = %.6f %s' % (to_currency.name, currency.rate, currency.name)
-             else:
-                 currency.rate_string = ''
  • rate
  • inverse_rate
  • rate_string

Back to entity