From e788c040f63e1cfb0026339871c94fbdf8d7bc9a Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Wed, 11 Dec 2019 13:21:42 +0000 Subject: [PATCH] [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) --- addons/website/controllers/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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/', 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/'], type='json', auth="public", methods=['POST'], website=True)