Odoo Help

Welcome!

This community 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.

0

Current user's Language

By
Mohamed Magdy
on 2/16/14, 5:46 PM 1,672 views

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

0
a.schenkels
On 2/18/14, 6:12 PM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 2/16/14, 5:46 PM
Seen: 1672 times
Last updated: 3/16/15, 8:10 AM