From 91a3bfc34a876e7716369fe0874709c83ca54c86 Mon Sep 17 00:00:00 2001 From: Ahmad Khanalizadeh Date: Wed, 14 Sep 2022 07:57:14 +0000 Subject: [PATCH] [FIX] base: use time zone aware display field for currency rates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce: 1. change system and admin's time zone to one with a different date than UTC 2. enable multi-currency in the accounting module 3. add rates for the current date in local time zone and UTC 4. go to settings > currencies 5. the rate for the UTC date is displayed To fix this, we should use a time zone aware field in `res_currency`. opw-2945108 closes odoo/odoo#101686 X-original-commit: 2f1d8d6db4efab86d35f362138e80e03692537dd Signed-off-by: William André (wan) Signed-off-by: Khanalizadeh Ahmad (khah) --- odoo/addons/base/models/res_currency.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/addons/base/models/res_currency.py b/odoo/addons/base/models/res_currency.py index ef9ffb58cd6..48da5fb9af8 100644 --- a/odoo/addons/base/models/res_currency.py +++ b/odoo/addons/base/models/res_currency.py @@ -118,7 +118,7 @@ class Currency(models.Model): @api.depends('rate_ids.rate') def _compute_current_rate(self): - date = self._context.get('date') or fields.Date.today() + date = self._context.get('date') or fields.Date.context_today(self) company = self.env['res.company'].browse(self._context.get('company_id')) or self.env.company # the subquery selects the last rate before 'date' for the given currency/company currency_rates = self._get_rates(company, date)