Skip to content
Snippets Groups Projects
Commit dc771b1a authored by jvm-odoo's avatar jvm-odoo Committed by Jason Van Malder
Browse files

[FIX] http_routing: fix context language used when not available


A customer reported a problem when he deleted a language on the
website app.

In some cases, if you go on the odoo's generated website as a public
user let's imagine the following url: website.com/en_GB

The lang is saved in a cookie and sent to the context.

If you delete the language from the website languages (without
deactivating it) and you go on website.com as a public user,
the method will try to use the context or the cookie value which is
'en_GB' and it crashes.

This commit makes sure that the language is available

OPW-2129580

closes odoo/odoo#41007

X-original-commit: f3e9ca13
Signed-off-by: default avatarJason Van Malder <jasonvanmalder@users.noreply.github.com>
parent 5ef68945
No related branches found
No related tags found
No related merge requests found
......@@ -391,8 +391,9 @@ class IrHttp(models.AbstractModel):
lang = Lang._lang_get(nearest_lang)
else:
nearest_ctx_lg = not is_a_bot and cls.get_nearest_lang(request.env.context['lang'])
preferred_lang = Lang._lang_get(cook_lang or nearest_ctx_lg) or cls._get_default_lang()
lang = preferred_lang
nearest_ctx_lg = nearest_ctx_lg in lang_codes and nearest_ctx_lg
preferred_lang = Lang._lang_get(cook_lang or nearest_ctx_lg)
lang = preferred_lang or cls._get_default_lang()
request.lang = lang
context['lang'] = lang.code
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment