Browse Source

[MIG] base_user_role: Migration to 13.0

14.0
sebalix 5 years ago
committed by Jesús Alan Ramos Rodríguez
parent
commit
6337a5968e
  1. 2
      base_user_role/__manifest__.py
  2. 6
      base_user_role/data/ir_module_category.xml
  3. 7
      base_user_role/models/role.py
  4. 3
      base_user_role/models/user.py
  5. 2
      base_user_role/readme/CONTRIBUTORS.rst
  6. 8
      base_user_role/readme/USAGE.rst
  7. 1
      base_user_role/views/role.xml

2
base_user_role/__manifest__.py

@ -4,7 +4,7 @@
{ {
'name': 'User roles', 'name': 'User roles',
'version': '12.0.1.0.0',
'version': '13.0.1.0.0',
'category': 'Tools', 'category': 'Tools',
'author': 'ABF OSIELL, Odoo Community Association (OCA)', 'author': 'ABF OSIELL, Odoo Community Association (OCA)',
'license': 'LGPL-3', 'license': 'LGPL-3',

6
base_user_role/data/ir_module_category.xml

@ -4,6 +4,12 @@
--> -->
<odoo> <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"> <record model="ir.module.category" id="ir_module_category_role">
<field name='name'>User roles</field> <field name='name'>User roles</field>
</record> </record>

7
base_user_role/models/role.py

@ -32,7 +32,6 @@ class ResUsersRole(models.Model):
string="Associated category", string="Associated category",
help="Associated group's category") help="Associated group's category")
@api.multi
@api.depends('line_ids.user_id') @api.depends('line_ids.user_id')
def _compute_user_ids(self): def _compute_user_ids(self):
for role in self: for role in self:
@ -44,20 +43,17 @@ class ResUsersRole(models.Model):
new_record.update_users() new_record.update_users()
return new_record return new_record
@api.multi
def write(self, vals): def write(self, vals):
res = super(ResUsersRole, self).write(vals) res = super(ResUsersRole, self).write(vals)
self.update_users() self.update_users()
return res return res
@api.multi
def unlink(self): def unlink(self):
users = self.mapped('user_ids') users = self.mapped('user_ids')
res = super(ResUsersRole, self).unlink() res = super(ResUsersRole, self).unlink()
users.set_groups_from_roles(force=True) users.set_groups_from_roles(force=True)
return res return res
@api.multi
def update_users(self): def update_users(self):
"""Update all the users concerned by the roles identified by `ids`.""" """Update all the users concerned by the roles identified by `ids`."""
users = self.mapped('user_ids') users = self.mapped('user_ids')
@ -87,7 +83,6 @@ class ResUsersRoleLine(models.Model):
'res.company', 'Company', 'res.company', 'Company',
default=lambda self: self.env.user.company_id) default=lambda self: self.env.user.company_id)
@api.multi
@api.constrains('user_id', 'company_id') @api.constrains('user_id', 'company_id')
def _check_company(self): def _check_company(self):
for record in self: for record in self:
@ -98,7 +93,6 @@ class ResUsersRoleLine(models.Model):
_('User "{}" does not have access to the company "{}"') _('User "{}" does not have access to the company "{}"')
.format(record.user_id.name, record.company_id.name)) .format(record.user_id.name, record.company_id.name))
@api.multi
@api.depends('date_from', 'date_to') @api.depends('date_from', 'date_to')
def _compute_is_enabled(self): def _compute_is_enabled(self):
today = datetime.date.today() today = datetime.date.today()
@ -113,7 +107,6 @@ class ResUsersRoleLine(models.Model):
if today > date_to: if today > date_to:
role_line.is_enabled = False role_line.is_enabled = False
@api.multi
def unlink(self): def unlink(self):
users = self.mapped('user_id') users = self.mapped('user_id')
res = super(ResUsersRoleLine, self).unlink() res = super(ResUsersRoleLine, self).unlink()

3
base_user_role/models/user.py

@ -31,7 +31,6 @@ class ResUsers(models.Model):
}) })
return default_values return default_values
@api.multi
@api.depends('role_line_ids.role_id') @api.depends('role_line_ids.role_id')
def _compute_role_ids(self): def _compute_role_ids(self):
for user in self: for user in self:
@ -43,13 +42,11 @@ class ResUsers(models.Model):
new_record.set_groups_from_roles() new_record.set_groups_from_roles()
return new_record return new_record
@api.multi
def write(self, vals): def write(self, vals):
res = super(ResUsers, self).write(vals) res = super(ResUsers, self).write(vals)
self.sudo().set_groups_from_roles() self.sudo().set_groups_from_roles()
return res return res
@api.multi
def _get_enabled_roles(self): def _get_enabled_roles(self):
return self.role_line_ids.filtered( return self.role_line_ids.filtered(
lambda rec: rec.is_enabled and lambda rec: rec.is_enabled and

2
base_user_role/readme/CONTRIBUTORS.rst

@ -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) * Duc, Dao Dong <duc.dd@komit-consulting.com> (https://komit-consulting.com)
* Jean-Charles Drubay <jc@komit-consulting.com> (https://komit-consulting.com) * Jean-Charles Drubay <jc@komit-consulting.com> (https://komit-consulting.com)

8
base_user_role/readme/USAGE.rst

@ -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: To use this module, you need to:
#. Go to Configuration / Users / Users choose user and set Roles: #. Go to Configuration / Users / Users choose user and set Roles:

1
base_user_role/views/role.xml

@ -62,7 +62,6 @@
<field name="name">Roles</field> <field name="name">Roles</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">res.users.role</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"/> <field name="view_id" ref="view_res_users_role_tree"/>
</record> </record>

Loading…
Cancel
Save