Browse Source
Merge pull request #922 from osiell/8.0-base_user_role_backport_features
[8.0] base_user_role: backport features from 9.0 + Fix from 10.0
pull/1072/head
Stefan Rijnhart (Opener)
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
35 additions and
2 deletions
-
base_user_role/__openerp__.py
-
base_user_role/data/ir_module_category.xml
-
base_user_role/models/role.py
-
base_user_role/views/user.xml
|
|
@ -15,6 +15,7 @@ |
|
|
|
], |
|
|
|
'data': [ |
|
|
|
'security/ir.model.access.csv', |
|
|
|
'data/ir_module_category.xml', |
|
|
|
'data/ir_cron.xml', |
|
|
|
'views/role.xml', |
|
|
|
'views/user.xml', |
|
|
|
|
|
@ -0,0 +1,12 @@ |
|
|
|
<?xml version="1.0" encoding="utf-8"?> |
|
|
|
<!-- Copyright 2016 ABF OSIELL <http://osiell.com> |
|
|
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
|
|
|
<openerp> |
|
|
|
<data> |
|
|
|
|
|
|
|
<record model="ir.module.category" id="ir_module_category_role"> |
|
|
|
<field name='name'>User roles</field> |
|
|
|
</record> |
|
|
|
|
|
|
|
</data> |
|
|
|
</openerp> |
|
|
@ -24,6 +24,12 @@ class ResUsersRole(models.Model): |
|
|
|
user_ids = fields.One2many( |
|
|
|
'res.users', string=u"Users", compute='_compute_user_ids') |
|
|
|
|
|
|
|
_defaults = { # pylint: disable=attribute-deprecated |
|
|
|
'category_id': api.model( |
|
|
|
lambda cls: cls.env.ref( |
|
|
|
'base_user_role.ir_module_category_role').id), |
|
|
|
} |
|
|
|
|
|
|
|
@api.multi |
|
|
|
@api.depends('line_ids.user_id') |
|
|
|
def _compute_user_ids(self): |
|
|
@ -42,6 +48,13 @@ class ResUsersRole(models.Model): |
|
|
|
self.update_users() |
|
|
|
return res |
|
|
|
|
|
|
|
@api.multi |
|
|
|
def unlink(self): |
|
|
|
users = self.mapped('user_id') |
|
|
|
res = super(ResUsersRole, self).unlink() |
|
|
|
users.set_groups_from_roles() |
|
|
|
return res |
|
|
|
|
|
|
|
@api.multi |
|
|
|
def update_users(self): |
|
|
|
"""Update all the users concerned by the roles identified by `ids`.""" |
|
|
@ -81,3 +94,10 @@ class ResUsersRoleLine(models.Model): |
|
|
|
date_to = fields.Date.from_string(role_line.date_to) |
|
|
|
if today > date_to: |
|
|
|
role_line.is_enabled = False |
|
|
|
|
|
|
|
@api.multi |
|
|
|
def unlink(self): |
|
|
|
users = self.mapped('user_id') |
|
|
|
res = super(ResUsersRoleLine, self).unlink() |
|
|
|
users.set_groups_from_roles() |
|
|
|
return res |
|
|
@ -9,7 +9,7 @@ |
|
|
|
<field name="model">res.users</field> |
|
|
|
<field name="inherit_id" ref="base.view_users_form"/> |
|
|
|
<field name="arch" type="xml"> |
|
|
|
<notebook position="inside"> |
|
|
|
<xpath expr="//notebook/page[1]" position="before"> |
|
|
|
<page string="Roles"> |
|
|
|
<field name="role_line_ids" nolabel="1"> |
|
|
|
<tree editable="bottom" colors="grey: not is_enabled;"> |
|
|
@ -20,7 +20,7 @@ |
|
|
|
</tree> |
|
|
|
</field> |
|
|
|
</page> |
|
|
|
</notebook> |
|
|
|
</xpath> |
|
|
|
</field> |
|
|
|
</record> |
|
|
|
|
|
|
|