[IMP] multi companies on users
bzr revid: fp@tinyerp.com-20091209111834-kmicjotdgrnyquad
This commit is contained in:
@@ -38,7 +38,8 @@ class res_company(osv.osv):
|
||||
'rml_header2' : fields.text('RML Internal Header'),
|
||||
'logo' : fields.binary('Logo'),
|
||||
'currency_id': fields.many2one('res.currency', 'Currency', required=True),
|
||||
'currency_ids': fields.one2many('res.currency', 'company_id', 'Currency')
|
||||
'currency_ids': fields.one2many('res.currency', 'company_id', 'Currency'),
|
||||
'user_ids': fields.many2many('res.users', 'res_company_users_rel', 'cid', 'user_id', 'Accepted Users')
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -140,8 +140,8 @@ class users(osv.osv):
|
||||
'groups_id': fields.many2many('res.groups', 'res_groups_users_rel', 'uid', 'gid', 'Groups'),
|
||||
'roles_id': fields.many2many('res.roles', 'res_roles_users_rel', 'uid', 'rid', 'Roles'),
|
||||
'rules_id': fields.many2many('ir.rule.group', 'user_rule_group_rel', 'user_id', 'rule_group_id', 'Rules'),
|
||||
'company_id': fields.many2one('res.company', 'Company', help="The company this user is currently working on."),
|
||||
'company_ids':fields.many2many('res.company','res_company_users_rel','user_id','cid','Accepted Companies'),
|
||||
'company_id': fields.many2one('res.company', 'Company', help="The company this user is currently working on.", required=True),
|
||||
'company_ids':fields.many2many('res.company','res_company_users_rel','user_id','cid','Accepted Companies'),
|
||||
'context_lang': fields.selection(_lang_get, 'Language', required=True),
|
||||
'context_tz': fields.selection(_tz_get, 'Timezone', size=64),
|
||||
'company': fields.selection(_companies_get, 'Company', size=64),
|
||||
@@ -209,9 +209,6 @@ class users(osv.osv):
|
||||
ok=False
|
||||
if ok:
|
||||
uid = 1
|
||||
context_company=values.get('company',False)
|
||||
if context_company:
|
||||
values.update({'company_id':context_company})
|
||||
res = super(users, self).write(cr, uid, ids, values, *args, **argv)
|
||||
self.company_get.clear_cache(cr.dbname)
|
||||
# Restart the cache on the company_get method
|
||||
@@ -280,6 +277,16 @@ class users(osv.osv):
|
||||
'type': 'ir.actions.act_window',
|
||||
'target':'new',
|
||||
}
|
||||
|
||||
def _check_company(self, cursor, user, ids):
|
||||
for user in self.browse(cursor, user, ids):
|
||||
if user.company_ids and (user.company_id.id not in map(lambda x: x.id, user.company_ids)):
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_check_company, 'This user can not connect using this company !', ['company_id']),
|
||||
]
|
||||
users()
|
||||
|
||||
class groups2(osv.osv): ##FIXME: Is there a reason to inherit this object ?
|
||||
|
||||
+3
-1
@@ -1051,9 +1051,11 @@ class orm_template(object):
|
||||
attrs = {'views': views}
|
||||
if node.get('widget') and node.get('widget') == 'selection':
|
||||
# We can not use the 'string' domain has it is defined according to the record !
|
||||
dom = None
|
||||
dom = []
|
||||
if column._domain and not isinstance(column._domain, (str, unicode)):
|
||||
dom = column._domain
|
||||
dom += eval(node.get('domain','[]'), {'uid':user, 'time':time})
|
||||
print dom, node.get('name')
|
||||
attrs['selection'] = self.pool.get(relation).name_search(cr, user, '', dom, context=context)
|
||||
if (node.get('required') and not int(node.get('required'))) or not column.required:
|
||||
attrs['selection'].append((False,''))
|
||||
|
||||
Reference in New Issue
Block a user