[IMP] add an implication relation between groups

bzr revid: rco@openerp.com-20110727131147-yiqgzy3sjv3ismvi
This commit is contained in:
Raphael Collet 2011-07-27 15:11:47 +02:00
parent e0f401bae4
commit 398d401724
1 changed files with 24 additions and 0 deletions

View File

@ -526,6 +526,30 @@ class users(osv.osv):
users()
class groups2(osv.osv):
_inherit = 'res.groups'
_columns = {
'implied_ids': fields.many2many('res.groups', 'res_groups_implied_rel', 'gid', 'hid',
string='Inherits', help='Users of this group automatically inherit those groups'),
}
def implied_groups(self, cr, uid, ids, context=None):
"return all groups recursively implied by the given ids"
closure = set()
todo = self.browse(cr, uid, ids, context)
while todo:
g = todo.pop()
if g.id not in closure:
closure.add(g.id)
todo.extend(g.implied_ids)
return list(closure)
groups2()
class res_config_view(osv.osv_memory):
_name = 'res.config.view'
_inherit = 'res.config'