diff options
| author | Romain Derie <rde@odoo.com> | 2019-12-11 13:21:42 +0000 |
|---|---|---|
| committer | Romain Derie <rde@odoo.com> | 2019-12-11 13:33:22 +0000 |
| commit | e788c040f63e1cfb0026339871c94fbdf8d7bc9a (patch) | |
| tree | 2dc1c4ff361001ec300959cee7acb117d6d34951 /addons | |
| parent | 0f2a500f0e74f7e60d806217296752ee69791d4d (diff) | |
[FIX] website: set correct value in frontend_lang cookie
Before this commit, the `url_code` field value was stored in the cookie instead
of the `code` field.
This was making the language selector in the frontend to not change the lang
correctly when trying to access the website default lang, ONLY for the lang
having an `url_code` different than its `code` value (typically the case for
principal languages).
Step to reproduce:
- Add `fi_FI` as main lang on website
- Visit frontend and change lang to `Suomi`, it won't change
This behavior was only related to the language switcher. It did not affect
dispatching (if correct lang in url) and nearest lang finder.
Fixes #41522
closes odoo/odoo#41728
X-original-commit: b62b2828552abb38c8adc74c69cb427c3fd98605
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/website/controllers/main.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index fbc71425bf8..3cda9d5348f 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -113,11 +113,13 @@ class Website(Home): @http.route('/website/lang/<lang>', type='http', auth="public", website=True, multilang=False) def change_lang(self, lang, r='/', **kwargs): + """ :param lang: supposed to be value of `url_code` field """ if lang == 'default': lang = request.website.default_lang_id.url_code r = '/%s%s' % (lang, r or '/') redirect = werkzeug.utils.redirect(r or ('/%s' % lang), 303) - redirect.set_cookie('frontend_lang', lang) + lang_code = request.env['res.lang']._lang_get_code(lang) + redirect.set_cookie('frontend_lang', lang_code) return redirect @http.route(['/website/country_infos/<model("res.country"):country>'], type='json', auth="public", methods=['POST'], website=True) |
