Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda

Hello,

I am using odoo11. i have enable multi language feature for eg English, French, Spanish.  My problem is into website side when i switch the language english to french and go to backend at that time odoo loads the menu into english language not into french language. but once the page is reload into backend after that it will reload the menu into the french language. 

I want the language into odoo backend  which is user switch on odoo frontend

Please help me to resolve the issue.

Thanks in advance.

Avatar
Buang
Penulis Jawaban Terbai

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.

CODE: 

from odoo.addons.website.controllers.main import Website
from odoo.http import request
class WebsiteExt(Website):
    @http.route()
    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

Avatar
Buang
Jawaban Terbai

Thank you Mitul, It's working a lot for me.

Avatar
Buang
Jawaban Terbai

Hi,

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

Or

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

Avatar
Buang
Penulis

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

Post Terkait Replies Tampilan Aktivitas
3
Sep 15
4627
0
Mar 18
2559
1
Feb 18
4117
1
Sep 15
9723
2
Des 19
2502