From 63de98b9b4a329705a5faaab74bc641e6b29eb54 Mon Sep 17 00:00:00 2001 From: wan Date: Tue, 1 Oct 2019 08:28:42 +0000 Subject: [FIX] *: remove en_US as fallback for lang code en_US may not be activated as it is possible to create a database in another language using the database manager. When trying to install a chart of account, the tax return entry tried to format a date at the installation of the module, with no lang in the context. The fallback was made on en_US but an error is raised if that language is not activated. As it is a very common scenario to retrieve a language from the context, add a generic tool method to do it. Replace and closes odoo/odoo#37629 closes odoo/odoo#37568 Signed-off-by: Martin Trigaux (mat) --- addons/web/models/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/web/models') diff --git a/addons/web/models/models.py b/addons/web/models/models.py index e85de4f6c45..3ef871cabe0 100644 --- a/addons/web/models/models.py +++ b/addons/web/models/models.py @@ -5,6 +5,7 @@ import pytz from odoo import _, api, fields, models from odoo.osv.expression import AND from odoo.tools import lazy +from odoo.tools.misc import get_lang from odoo.exceptions import UserError @@ -142,7 +143,7 @@ class Base(models.AbstractModel): # Again, imitating what _read_group_format_result and _read_group_prepare_data do if group_by_value and field_type in ['date', 'datetime']: - locale = self._context.get('lang') or 'en_US' + locale = get_lang(self.env).code group_by_value = fields.Datetime.to_datetime(group_by_value) group_by_value = pytz.timezone('UTC').localize(group_by_value) tz_info = None -- cgit v1.2.3