Skip to content

Commit

Permalink
fixup! fixup! fixup! [FIX] http: Set lang in context only for existin…
Browse files Browse the repository at this point in the history
…g langs
  • Loading branch information
tbe-odoo committed Jan 16, 2018
1 parent 983e4c0 commit a950205
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions odoo/addons/base/res/res_lang.py
Expand Up @@ -271,17 +271,13 @@ def format(self, percent, value, grouping=False, monetary=False):

@classmethod
def _check_setup_lang(cls, lang, fallback):
cr = cls.pool.cursor()

self = api.Environment(cr, SUPERUSER_ID, {})[cls._name]
if self.search_count([('code', '=', lang), ('active', '=', True)]) == 0:
if lang.lower() != fallback.lower() and self.search_count([('code', '=', fallback), ('active', '=', True)]) != 0:
lang = fallback
else:
lang = 'en_US'

cr.close()

with cls.pool.cursor() as cr:
self = api.Environment(cr, SUPERUSER_ID, {})[cls._name]
if self.search_count([('code', '=', lang), ('active', '=', True)]) == 0:
if lang.lower() != fallback.lower() and self.search_count([('code', '=', fallback), ('active', '=', True)]) != 0:
lang = fallback
else:
lang = 'en_US'
return lang


Expand Down

0 comments on commit a950205

Please sign in to comment.