admin user is not restricted by roles

bzr revid: chs@tinyerp.com-20081027125413-lusm89mme25cclm8
This commit is contained in:
Christophe Simonis 2008-10-27 13:54:13 +01:00
parent 348d01795a
commit f7273ecbc7
2 changed files with 11 additions and 10 deletions

View File

@ -831,14 +831,15 @@ class orm_template(object):
continue
ok = True
serv = netsvc.LocalService('object_proxy')
user_roles = serv.execute_cr(cr, user, 'res.users', 'read', [user], ['roles_id'])[0]['roles_id']
cr.execute("select role_id from wkf_transition where signal='%s'" % button.getAttribute('name'))
roles = cr.fetchall()
for role in roles:
if role[0]:
ok = ok and serv.execute_cr(cr, user, 'res.roles', 'check', user_roles, role[0])
if user != 1: # admin user has all roles
serv = netsvc.LocalService('object_proxy')
user_roles = serv.execute_cr(cr, user, 'res.users', 'read', [user], ['roles_id'])[0]['roles_id']
cr.execute("select role_id from wkf_transition where signal='%s'" % button.getAttribute('name'))
roles = cr.fetchall()
for role in roles:
if role[0]:
ok = ok and serv.execute_cr(cr, user, 'res.roles', 'check', user_roles, role[0])
if not ok:
button.setAttribute('readonly', '1')

View File

@ -101,8 +101,8 @@ def check(cr, workitem, ident, transition, signal):
if transition['signal']:
ok = (signal==transition['signal'])
if transition['role_id']:
uid = ident[0]
uid = ident[0]
if transition['role_id'] and uid != 1:
serv = netsvc.LocalService('object_proxy')
user_roles = serv.execute_cr(cr, uid, 'res.users', 'read', [uid], ['roles_id'])[0]['roles_id']
ok = ok and serv.execute_cr(cr, uid, 'res.roles', 'check', user_roles, transition['role_id'])