[FIX] issue with OpenERP's weird arabic locale leading to datejs not knowing what locale file to load, and the client not correctly loading as a result

lp bug: https://launchpad.net/bugs/922490 fixed

bzr revid: xmo@openerp.com-20120127131746-aiyudmhd4irzex7w
This commit is contained in:
Xavier Morel 2012-01-27 14:17:46 +01:00
parent b3619417d1
commit 28bdd074d5
1 changed files with 22 additions and 0 deletions

View File

@ -1,5 +1,6 @@
#!/usr/bin/python
import datetime
import babel
import dateutil.relativedelta
import logging
import time
@ -117,8 +118,29 @@ class OpenERPSession(object):
assert self._uid, "The user needs to be logged-in to initialize his context"
self.context = self.build_connection().get_user_context() or {}
self.context['uid'] = self._uid
self._fix_lang(self.context)
return self.context
def _fix_lang(self, context):
""" OpenERP provides languages which may not make sense and/or may not
be understood by the web client's libraries.
Fix those here.
:param dict context: context to fix
"""
lang = context['lang']
# inane OpenERP locale
if lang == 'ar_AR':
lang = 'ar'
# lang to lang_REGION (datejs only handles lang_REGION, no bare langs)
if lang in babel.core.LOCALE_ALIASES:
lang = babel.core.LOCALE_ALIASES[lang]
context['lang'] = lang
@property
def base_eval_context(self):
""" Default evaluation context for the session.