[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
This commit is contained in:
@@ -606,8 +606,20 @@
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Role">
|
||||
<field colspan="4" name="name" select="1"/>
|
||||
<field colspan="4" name="parent_id"/>
|
||||
<field name="name" select="1"/>
|
||||
<field name="parent_id"/>
|
||||
<separator string="Description" colspan="4"/>
|
||||
<field name="description" nolabel="1" colspan="4"/>
|
||||
<separator string="Workflow transitions" colspan="4"/>
|
||||
<field name="workflow_transition_ids" nolabel="1" colspan="4">
|
||||
<tree string="Workflow transitions">
|
||||
<field name="wkf_id"/>
|
||||
<field name="act_from"/>
|
||||
<field name="act_to"/>
|
||||
<field name="signal"/>
|
||||
<field name="condition"/>
|
||||
</tree>
|
||||
</field>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
@@ -619,6 +631,8 @@
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Roles">
|
||||
<field name="name"/>
|
||||
<field name="parent_id"/>
|
||||
<field name="description"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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,))
|
||||
|
||||
Reference in New Issue
Block a user