[FIX] http: setup_lang in Safari
When not logged in the webstie on Safari and clicking on "Have a Question? Chat with us", it creates a mail.channel from get_mail_channel and it also creates a translation. But with Safari, the accept_languages is set with the value 'fr-fr', and this value was set in the context as the lang='fr_fr'. So when the translation was created, a bad insert query was raised in sql because the lang didn't exist in the res.lang table. When a translation is created, the function _get_languages checked that the language is in the table. So it was impossible to use the chatter when the user is not logged. NB: interseting functions to see: -setup_lang in odoo/http.py -_dispatch in addons/website/models/ir_http.py -get_mail_channel in addons/im_livechat/models/im_livechat_channel.py opw:716519
This commit is contained in:
parent
1600216c1d
commit
5761b9a388
|
@ -1357,9 +1357,16 @@ class Root(object):
|
||||||
httprequest.session.db = db_monodb(httprequest)
|
httprequest.session.db = db_monodb(httprequest)
|
||||||
|
|
||||||
def setup_lang(self, httprequest):
|
def setup_lang(self, httprequest):
|
||||||
if not "lang" in httprequest.session.context:
|
if "lang" not in httprequest.session.context:
|
||||||
lang = httprequest.accept_languages.best or "en_US"
|
alang = httprequest.accept_languages.best or "en-US"
|
||||||
lang = babel.core.LOCALE_ALIASES.get(lang, lang).replace('-', '_')
|
try:
|
||||||
|
code, territory, _, _ = babel.core.parse_locale(alang, sep='-')
|
||||||
|
if territory:
|
||||||
|
lang = '%s_%s' % (code, territory)
|
||||||
|
else:
|
||||||
|
lang = babel.code.LOCALE_ALIASES[code]
|
||||||
|
except (ValueError, KeyError):
|
||||||
|
lang = 'en_US'
|
||||||
httprequest.session.context["lang"] = lang
|
httprequest.session.context["lang"] = lang
|
||||||
|
|
||||||
def get_request(self, httprequest):
|
def get_request(self, httprequest):
|
||||||
|
|
Loading…
Reference in New Issue