[IMP] base: Improve get_companymethod in res.user model
authorHarry (Open ERP) <hmo@tinyerp.com>
Fri, 19 Feb 2010 11:05:41 +0000 (16:35 +0530)
committerHarry (Open ERP) <hmo@tinyerp.com>
Fri, 19 Feb 2010 11:05:41 +0000 (16:35 +0530)
bzr revid: hmo@tinyerp.com-20100219110541-9g1oh5pg0krb2sve

bin/addons/base/res/res_user.py

index 550a1a0..eb4ca57 100644 (file)
@@ -229,8 +229,9 @@ class users(osv.osv):
     def _get_company(self,cr, uid, context={}, uid2=False):
         if not uid2:
             uid2 = uid
-        user = self.pool.get('res.users').browse(cr, uid, uid2, context)
-        return user.company_id.id
+        user = self.pool.get('res.users').read(cr, uid, uid2, ['company_id'], context)
+        company_id = user.get('company_id', False)
+        return company_id and company_id[0] or False
 
     def _get_menu(self,cr, uid, context={}):
         ids = self.pool.get('ir.actions.act_window').search(cr, uid, [('usage','=','menu')])