diff options
| author | wan <wan@odoo.com> | 2019-10-01 08:28:42 +0000 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2019-10-01 10:05:17 +0000 |
| commit | 63de98b9b4a329705a5faaab74bc641e6b29eb54 (patch) | |
| tree | fff61ab5fb72d1059190e069c0e0d137e09e40a8 /addons/website_event/controllers/main.py | |
| parent | f28f787c10ad320b562610952f9e26279872f8b7 (diff) | |
[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) <mat@odoo.com>
Diffstat (limited to 'addons/website_event/controllers/main.py')
| -rw-r--r-- | addons/website_event/controllers/main.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/addons/website_event/controllers/main.py b/addons/website_event/controllers/main.py index 1476c02da8a..20031a67781 100644 --- a/addons/website_event/controllers/main.py +++ b/addons/website_event/controllers/main.py @@ -12,6 +12,7 @@ from odoo import fields, http, _ from odoo.addons.http_routing.models.ir_http import slug from odoo.addons.website.controllers.main import QueryURL from odoo.http import request +from odoo.tools.misc import get_lang class WebsiteEventController(http.Controller): @@ -229,7 +230,7 @@ class WebsiteEventController(http.Controller): def get_formated_date(self, event): start_date = fields.Datetime.from_string(event.date_begin).date() end_date = fields.Datetime.from_string(event.date_end).date() - month = babel.dates.get_month_names('abbreviated', locale=event.env.context.get('lang') or 'en_US')[start_date.month] + month = babel.dates.get_month_names('abbreviated', locale=get_lang(event.env).code)[start_date.month] return ('%s %s%s') % (month, start_date.strftime("%e"), (end_date != start_date and ("-" + end_date.strftime("%e")) or "")) @http.route('/event/get_country_event_list', type='json', auth='public', website=True) |
