From 648c344cdf152bdae898b40087748efebb8c31b0 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Tue, 25 Mar 2008 08:47:26 +0000 Subject: [PATCH] optimised the code for button signal check for the role and also check role hierarchy sing inbuilt function bzr revid: mga@tinyerp.com-b4b8e430f8339a0a5e5dce4ee593d1bf31cfb31a --- bin/osv/orm.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 4afa2a1696f..3c5fb2f6dde 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -1545,18 +1545,20 @@ class orm(object): if button.getAttribute('type') == 'object': continue - #check for the signal, related role and associeated groups and set attribute according to that + 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]: - cr.execute("select count(*) from res_roles_users_rel where uid='%s' and rid in (%s)" % (user,','.join([str(x) for x in role]))) - res = cr.fetchall() - if res[0][0] == 0: - button.setAttribute('readonly', '1') - else: - button.setAttribute('readonly', '0') - + ok = ok and serv.execute_cr(cr, user, 'res.roles', 'check', user_roles, role[0]) + + if not ok: + button.setAttribute('readonly', '1') + else: + button.setAttribute('readonly', '0') arch = node.toxml(encoding="utf-8").replace('\t', '')