|
|
@ -21,7 +21,7 @@ from odoo import models, fields, api |
|
|
|
|
|
|
|
class Groups(models.AbstractModel): |
|
|
|
|
|
|
|
_name = 'muk_utils.groups' |
|
|
|
_name = 'muk_utils.mixins.groups' |
|
|
|
|
|
|
|
_parent_store = True |
|
|
|
_parent_name = "parent_group" |
|
|
@ -50,9 +50,7 @@ class Groups(models.AbstractModel): |
|
|
|
def add(name, field): |
|
|
|
if name not in self._fields: |
|
|
|
self._add_field(name, field) |
|
|
|
base, model = self._name.split(".") |
|
|
|
add('parent_group', fields.Many2one( |
|
|
|
_module=base, |
|
|
|
comodel_name=self._name, |
|
|
|
string='Parent Group', |
|
|
|
ondelete='cascade', |
|
|
@ -60,13 +58,11 @@ class Groups(models.AbstractModel): |
|
|
|
index=True, |
|
|
|
automatic=True)) |
|
|
|
add('child_groups', fields.One2many( |
|
|
|
_module=base, |
|
|
|
comodel_name=self._name, |
|
|
|
inverse_name='parent_group', |
|
|
|
string='Child Groups', |
|
|
|
automatic=True)) |
|
|
|
add('groups', fields.Many2many( |
|
|
|
_module=base, |
|
|
|
comodel_name='res.groups', |
|
|
|
relation='%s_groups_rel' % (self._table), |
|
|
|
column1='gid', |
|
|
@ -74,7 +70,6 @@ class Groups(models.AbstractModel): |
|
|
|
string='Groups', |
|
|
|
automatic=True)) |
|
|
|
add('explicit_users', fields.Many2many( |
|
|
|
_module=base, |
|
|
|
comodel_name='res.users', |
|
|
|
relation='%s_explicit_users_rel' % (self._table), |
|
|
|
column1='gid', |
|
|
@ -82,7 +77,6 @@ class Groups(models.AbstractModel): |
|
|
|
string='Explicit Users', |
|
|
|
automatic=True)) |
|
|
|
add('users', fields.Many2many( |
|
|
|
_module=base, |
|
|
|
comodel_name='res.users', |
|
|
|
relation='%s_users_rel' % (self._table), |
|
|
|
column1='gid', |
|
|
@ -100,7 +94,7 @@ class Groups(models.AbstractModel): |
|
|
|
# Read, View |
|
|
|
#---------------------------------------------------------- |
|
|
|
|
|
|
|
@api.depends('parent_group.users', 'groups', 'groups.users', 'explicit_users') |
|
|
|
@api.depends('parent_group', 'parent_group.users', 'groups', 'groups.users', 'explicit_users') |
|
|
|
def _compute_users(self): |
|
|
|
print(self) |
|
|
|
for record in self: |