summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Simonis <chs@tinyerp.com>2008-10-27 13:54:13 +0100
committerChristophe Simonis <chs@tinyerp.com>2008-10-27 13:54:13 +0100
commitf7273ecbc7c02772e76dcac90dee6e1cdd78b28e (patch)
tree16dd207c643b60de73a5fe704b2deb5cd1e66bdf
parent348d01795afc470032d81b2597206a430be77142 (diff)
admin user is not restricted by roles
bzr revid: chs@tinyerp.com-20081027125413-lusm89mme25cclm8
-rw-r--r--bin/osv/orm.py17
-rw-r--r--bin/workflow/wkf_expr.py4
2 files changed, 11 insertions, 10 deletions
diff --git a/bin/osv/orm.py b/bin/osv/orm.py
index 7dabec92dbc..62d414c1eb3 100644
--- a/bin/osv/orm.py
+++ b/bin/osv/orm.py
@@ -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')
diff --git a/bin/workflow/wkf_expr.py b/bin/workflow/wkf_expr.py
index 73573a231d2..d2d37edb3b3 100644
--- a/bin/workflow/wkf_expr.py
+++ b/bin/workflow/wkf_expr.py
@@ -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'])