summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNans Lefebvre <len@odoo.com>2019-10-09 13:09:40 +0000
committerfw-bot <otis@odoo.com>2019-10-11 01:16:04 +0000
commit609ff1f0fe8892bb7fe28d41956c63e334417d39 (patch)
tree21f04cf5ba2565010123abe47c5c51613e4ceb98
parent4ef3a14ea35d7e63f5140d3b8772d2f8cd84d96b (diff)
[FIX] calendar: handle inactive system language or missing date format
It is possible to select "System (English)" as chosen language, or False in v12 or earlier versions. However, if the language has not been activated, then record_lang is an empty recordset, so record_lang.date_format is False, (respectively time_format), and so the formatting crashes. Note that if this happens, the calendar notification mechanism generates a crash at each page load. Instead we use get_lang which defaults to the most appropriate activated language: the one given in argument if it exists, or the company one. co-authored with @mart-e closes odoo/odoo#38445 X-original-commit: 738214f00dff33389e7211ee73eae76b196b7844 Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
-rw-r--r--addons/calendar/models/calendar.py14
1 files changed, 2 insertions, 12 deletions
diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py
index 12f64409f2d..9697a2c13b9 100644
--- a/addons/calendar/models/calendar.py
+++ b/addons/calendar/models/calendar.py
@@ -684,18 +684,8 @@ class Meeting(models.Model):
""" get current date and time format, according to the context lang
:return: a tuple with (format date, format time)
"""
- lang = self._context.get("lang")
- lang_params = {}
- if lang:
- record_lang = self.env['res.lang']._lang_get(lang)
- lang_params = {
- 'date_format': record_lang.date_format,
- 'time_format': record_lang.time_format
- }
-
- format_date = lang_params.get("date_format", '%B-%d-%Y')
- format_time = lang_params.get("time_format", '%I-%M %p')
- return (format_date, format_time)
+ lang = get_lang(self.env)
+ return (lang.date_format, lang.time_format)
@api.model
def _get_recurrent_fields(self):