Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
7348 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 9 15
4578
0
thg 3 18
2519
1
thg 2 18
4067
1
thg 9 15
9663
2
thg 12 19
2443