|
|
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 = ''
|
|