mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[MIG] base_user_role: Migration to 13.0
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
{
|
||||
'name': 'User roles',
|
||||
'version': '12.0.1.0.0',
|
||||
'version': '13.0.1.0.0',
|
||||
'category': 'Tools',
|
||||
'author': 'ABF OSIELL, Odoo Community Association (OCA)',
|
||||
'license': 'LGPL-3',
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
-->
|
||||
<odoo>
|
||||
|
||||
<!--
|
||||
This module category aims to be linked to role/group you create in your own
|
||||
module (field 'res.groups.category_id').
|
||||
By doing this you'll have the section 'User roles' in the "Access rights" tab
|
||||
on the user form which will regroup all roles/groups for a better visibility.
|
||||
-->
|
||||
<record model="ir.module.category" id="ir_module_category_role">
|
||||
<field name='name'>User roles</field>
|
||||
</record>
|
||||
|
||||
@@ -32,7 +32,6 @@ class ResUsersRole(models.Model):
|
||||
string="Associated category",
|
||||
help="Associated group's category")
|
||||
|
||||
@api.multi
|
||||
@api.depends('line_ids.user_id')
|
||||
def _compute_user_ids(self):
|
||||
for role in self:
|
||||
@@ -44,20 +43,17 @@ class ResUsersRole(models.Model):
|
||||
new_record.update_users()
|
||||
return new_record
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
res = super(ResUsersRole, self).write(vals)
|
||||
self.update_users()
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def unlink(self):
|
||||
users = self.mapped('user_ids')
|
||||
res = super(ResUsersRole, self).unlink()
|
||||
users.set_groups_from_roles(force=True)
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def update_users(self):
|
||||
"""Update all the users concerned by the roles identified by `ids`."""
|
||||
users = self.mapped('user_ids')
|
||||
@@ -87,7 +83,6 @@ class ResUsersRoleLine(models.Model):
|
||||
'res.company', 'Company',
|
||||
default=lambda self: self.env.user.company_id)
|
||||
|
||||
@api.multi
|
||||
@api.constrains('user_id', 'company_id')
|
||||
def _check_company(self):
|
||||
for record in self:
|
||||
@@ -98,7 +93,6 @@ class ResUsersRoleLine(models.Model):
|
||||
_('User "{}" does not have access to the company "{}"')
|
||||
.format(record.user_id.name, record.company_id.name))
|
||||
|
||||
@api.multi
|
||||
@api.depends('date_from', 'date_to')
|
||||
def _compute_is_enabled(self):
|
||||
today = datetime.date.today()
|
||||
@@ -113,7 +107,6 @@ class ResUsersRoleLine(models.Model):
|
||||
if today > date_to:
|
||||
role_line.is_enabled = False
|
||||
|
||||
@api.multi
|
||||
def unlink(self):
|
||||
users = self.mapped('user_id')
|
||||
res = super(ResUsersRoleLine, self).unlink()
|
||||
|
||||
@@ -31,7 +31,6 @@ class ResUsers(models.Model):
|
||||
})
|
||||
return default_values
|
||||
|
||||
@api.multi
|
||||
@api.depends('role_line_ids.role_id')
|
||||
def _compute_role_ids(self):
|
||||
for user in self:
|
||||
@@ -43,13 +42,11 @@ class ResUsers(models.Model):
|
||||
new_record.set_groups_from_roles()
|
||||
return new_record
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
res = super(ResUsers, self).write(vals)
|
||||
self.sudo().set_groups_from_roles()
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def _get_enabled_roles(self):
|
||||
return self.role_line_ids.filtered(
|
||||
lambda rec: rec.is_enabled and
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
* Sébastien Alix <sebastien.alix@osiell.com>
|
||||
* Sébastien Alix <sebastien.alix@camptocamp.com>
|
||||
* Duc, Dao Dong <duc.dd@komit-consulting.com> (https://komit-consulting.com)
|
||||
* Jean-Charles Drubay <jc@komit-consulting.com> (https://komit-consulting.com)
|
||||
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
[ This file must be present and contains the usage instructions
|
||||
for end-users. As all other rst files included in the README,
|
||||
it MUST NOT contain reStructuredText sections
|
||||
only body text (paragraphs, lists, tables, etc). Should you need
|
||||
a more elaborate structure to explain the addon, please create a
|
||||
Sphinx documentation (which may include this file as a "quick start"
|
||||
section). ]
|
||||
|
||||
To use this module, you need to:
|
||||
|
||||
#. Go to Configuration / Users / Users choose user and set Roles:
|
||||
|
||||
@@ -62,7 +62,6 @@
|
||||
<field name="name">Roles</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">res.users.role</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="view_res_users_role_tree"/>
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user