콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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.

아바타
취소
작성자 베스트 답변

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

아바타
취소
베스트 답변

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

아바타
취소
베스트 답변

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.

아바타
취소
작성자

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

관련 게시물 답글 화면 활동
3
9월 15
4862
0
3월 18
2650
1
2월 18
4276
1
9월 15
9916
2
12월 19
2719