跳至內容
選單
此問題已被標幟
2 回覆
13887 瀏覽次數

In OpenERP v7.0, I need to get the Language of the Current User. I did try to get session info from web/controllers/main.py In Class Home, i added this line:

 lang = self.get_lang(req)

get_lang is :

    def get_lang(self, req):
    ''' get the context lang, with direction properties
    '''
    #   raise osv.except_osv('',str(req.session.get_context().get('lang', 'en_US')))
    current_lang = req.session._uid and req.session.get_context().get('lang', 'en_US') or 'en_US'
    #        pdb.set_trace()

    default = {
        'code': current_lang,
        'direction': 'ltr', 
    }

    if not req.session._uid:
        return default
    context = req.session.get_context()    
    Model = req.session.model
    langobj = Model('res.lang').search([('code', '=', current_lang),], 0, False, False, context)
    lang = Model('res.lang').read(langobj[0], ['code', 'direction'], context) if langobj else None
    if not lang:
        return default

    return dict(lang)

but

req.session,_uid is always False

頭像
捨棄
最佳答案

odoo 11

self.env.user.lang

頭像
捨棄
最佳答案

Isn't the current user language set on the res_users/partner model?

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
3月 15
8573
5
5月 24
48764
0
3月 16
4679
0
5月 22
1777
1
2月 16
4863