[IMP] base: if company_ids is empty, it will be set with deafult value on user creation

bzr revid: hmo@tinyerp.com-20101011132252-wcej9vlsb6582w5x
This commit is contained in:
Harry (OpenERP) 2010-10-11 18:52:52 +05:30
parent f9eb2e0260
commit e232dd6638
1 changed files with 6 additions and 0 deletions

View File

@ -350,6 +350,12 @@ class users(osv.osv):
# User can write to a few of her own fields (but not her groups for example)
SELF_WRITEABLE_FIELDS = ['menu_tips','view', 'password', 'signature', 'action_id', 'company_id', 'user_email']
def create(self, cr, uid, vals, context=None):
if (not vals.get('company_ids',[])):
company_ids = self._get_companies(cr, uid, context=context)
if company_ids and len(company_ids): vals['company_ids'] = [(6, 0, company_ids)]
return super(users, self).create(cr, uid, vals, context=context)
def write(self, cr, uid, ids, values, context=None):
if not hasattr(ids, '__iter__'):
ids = [ids]