[IMP] res_user: users are create with company_id = actual company_id
authorChristophe Matthieu <chm@openerp.com>
Tue, 26 Mar 2013 14:18:58 +0000 (15:18 +0100)
committerChristophe Matthieu <chm@openerp.com>
Tue, 26 Mar 2013 14:18:58 +0000 (15:18 +0100)
bzr revid: chm@openerp.com-20130326141858-da0e1avhwoswa99e

openerp/addons/base/res/res_partner.py
openerp/addons/base/res/res_users.py

index 773f64f..db2b13a 100644 (file)
@@ -160,7 +160,7 @@ def _lang_get(self, cr, uid, context=None):
     return [(r['code'], r['name']) for r in res]
 
 POSTAL_ADDRESS_FIELDS = ('street', 'street2', 'zip', 'city', 'state_id', 'country_id')
-ADDRESS_FIELDS = POSTAL_ADDRESS_FIELDS + ('email', 'phone', 'fax', 'mobile', 'website', 'ref', 'lang')
+ADDRESS_FIELDS = POSTAL_ADDRESS_FIELDS + ('phone', 'fax', 'mobile', 'website', 'ref', 'lang')
 
 class res_partner(osv.osv, format_address):
     _description = 'Partner'
index 27adab9..eed6ed1 100644 (file)
@@ -251,6 +251,12 @@ class res_users(osv.osv):
     # User can read a few of his own fields
     SELF_READABLE_FIELDS = ['signature', 'company_id', 'login', 'email', 'name', 'image', 'image_medium', 'image_small', 'lang', 'tz', 'tz_offset', 'groups_id', 'partner_id', '__last_update']
 
+    def create(self, cr, uid, values, context=None):
+        user = self.read(cr, SUPERUSER_ID, uid, ['company_id', 'company_ids'], context=context)
+        values['company_id'] = user['company_id'] and user['company_id'][0] or None
+        values['company_ids'] = user['company_ids']
+        return super(res_users, self).create(cr, uid, values, context=context)
+
     def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
         def override_password(o):
             if 'password' in o and ('id' not in o or o['id'] != uid):