From 68a30421efc8b3c55469eae166d907ff596a0a13 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 20 Aug 2010 17:27:50 +0200 Subject: [PATCH] [IMP] res_roles: improved documentation and views: - added description field and o2m to wkf transitions - improved views: tooltips, layout - added related wkf_id field on transitions to display it in list view - added basic docstring on check() method bzr revid: odo@openerp.com-20100820152750-ad5ypnwwxjnzdfn9 --- bin/addons/base/ir/ir.xml | 18 ++++++++++++++++-- bin/addons/base/ir/workflow/workflow.py | 1 + bin/addons/base/res/res_user.py | 12 +++++++++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/bin/addons/base/ir/ir.xml b/bin/addons/base/ir/ir.xml index f84a0868709..f5422607d3f 100644 --- a/bin/addons/base/ir/ir.xml +++ b/bin/addons/base/ir/ir.xml @@ -606,8 +606,20 @@ form
- - + + + + + + + + + + + + + + @@ -619,6 +631,8 @@ + + diff --git a/bin/addons/base/ir/workflow/workflow.py b/bin/addons/base/ir/workflow/workflow.py index 7518700a3c3..dae77781503 100644 --- a/bin/addons/base/ir/workflow/workflow.py +++ b/bin/addons/base/ir/workflow/workflow.py @@ -151,6 +151,7 @@ class wkf_transition(osv.osv): 'condition': fields.char('Condition', required=True, size=128), 'act_from': fields.many2one('workflow.activity', 'Source Activity', required=True, select=True, ondelete='cascade'), 'act_to': fields.many2one('workflow.activity', 'Destination Activity', required=True, select=True, ondelete='cascade'), + 'wkf_id': fields.related('act_from','wkf_id', type='many2one', relation='workflow', string='Workflow', select=True), } _defaults = { 'condition': lambda *a: 'True', diff --git a/bin/addons/base/res/res_user.py b/bin/addons/base/res/res_user.py index 59351b80d71..99e75fd7ec3 100644 --- a/bin/addons/base/res/res_user.py +++ b/bin/addons/base/res/res_user.py @@ -93,13 +93,19 @@ class roles(osv.osv): _name = "res.roles" _columns = { 'name': fields.char('Role Name', size=64, required=True), - 'parent_id': fields.many2one('res.roles', 'Parent', select=True), + 'parent_id': fields.many2one('res.roles', 'Parent', select=True, + help="The parent role can be used to construct a hierarchy of roles. Parent roles inherit from the roles of their descendants."), 'child_id': fields.one2many('res.roles', 'parent_id', 'Children'), 'users': fields.many2many('res.users', 'res_roles_users_rel', 'rid', 'uid', 'Users'), - } - _defaults = { + 'description': fields.text('Description', help="Description of this role and where it is relevant in workflows and processes"), + 'workflow_transition_ids': fields.one2many('workflow.transition', 'role_id', 'Workflow Transitions', + help="The workflow transitions associated with this role"), } def check(self, cr, uid, ids, role_id): + """Verifies that the role with id ``role_id`` is granted directly or indirectly to a + user that possesses the roles with ids ``ids``. Indirectly means that one of the + roles with id in ``ids`` is an ancestor role of the role with id ``role_id``. + """ if role_id in ids: return True cr.execute('select parent_id from res_roles where id=%s', (role_id,))