summaryrefslogtreecommitdiff
path: root/odoo/models.py
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2017-04-20 10:16:29 +0200
committerChristophe Matthieu <chm@odoo.com>2017-04-20 10:47:43 +0200
commit6ecbbf8b96ccc8a3d954f12051a3e929422a4c3e (patch)
treee6f0d3fa4d9eeb48739bd7a9f8559b4f68b717cd /odoo/models.py
parented2bc6dbc3edbbe8205cb095473ee765f21360b5 (diff)
[FIX] models.py, account, calendar, product: lang in context can be None
Different method use self._context.get('lang', 'en_US') to get the lang value but, the lang in the context can be set to None (eg: copy method). When the context is used with a lang=None, the method can have a unexpected behavior or crashed (eg: if you try to format a datetime with a locale=None)
Diffstat (limited to 'odoo/models.py')
-rw-r--r--odoo/models.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/odoo/models.py b/odoo/models.py
index ca920c0ccf4..4c8dc9c6630 100644
--- a/odoo/models.py
+++ b/odoo/models.py
@@ -1846,7 +1846,7 @@ class BaseModel(object):
if ftype == 'many2one':
value = value[0]
elif ftype in ('date', 'datetime'):
- locale = self._context.get('lang', 'en_US')
+ locale = self._context.get('lang') or 'en_US'
fmt = DEFAULT_SERVER_DATETIME_FORMAT if ftype == 'datetime' else DEFAULT_SERVER_DATE_FORMAT
tzinfo = None
range_start = value