Odoo Help


3 Answers

Mitul Shingala

--Mitul Shingala--
--Mitul Shingala--

Odoo Developer

Mitul Shingala
1/30/19, 12:40 AM

Hello All,

I have found the solution of this problem and it works fine as i need. here i put some code. When user switch  language into website, so one controller is call and into that controller i have update my code. Whatever new language is select by user on website at that time i have updated that language into user language field(in backend). and update the context value. so now when user goes to backend, at that time user get the GUI in newly selected language which is selected by user on website.


from odoo.addons.website.controllers.main import Website
from odoo.http import request
class WebsiteExt(Website):
    def change_lang(self, lang, r='/', **kwargs):
    # this controller call when user switch the language into website
        res = super(WebsiteExt, self).change_lang(lang, r, **kwargs) # super call of the change_lang()
        if not request.env.user._is_public():
            request.env.user.partner_id.lang = lang
            request.env.user.lang = lang
            request.env['ir.http'].webclient_rendering_context() # call this method so the menu and session data will be reload.
        return res



You have to set the cookie by frontend_lang parameter when you redirect from website to /web url.


You can reload your page when user click on any menuitem and redirect to page by javascript.

1 Comment
Mitul Shingala
1/25/19, 5:24 AM

Thanks for your answer. i have also tried this frontend_lang parameter but doesn't work.

Ask a Question
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now