Browse Source

[MIG] base_user_role: Migration to 12.0

14.0
Duc Dao 6 years ago
committed by Jesús Alan Ramos Rodríguez
parent
commit
3cbb632748
  1. 52
      base_user_role/README.rst
  2. 5
      base_user_role/__manifest__.py
  3. 12
      base_user_role/models/role.py
  4. 18
      base_user_role/readme/CONFIGURE.rst
  5. 5
      base_user_role/readme/CONTRIBUTORS.rst
  6. 4
      base_user_role/readme/CREDITS.rst
  7. 19
      base_user_role/readme/DESCRIPTION.rst
  8. 4
      base_user_role/readme/ROADMAP.rst
  9. 13
      base_user_role/readme/USAGE.rst
  10. BIN
      base_user_role/static/description/user_form.png
  11. 5
      base_user_role/tests/test_user_role.py

52
base_user_role/README.rst

@ -6,71 +6,19 @@
User roles User roles
========== ==========
This module was written to extend the standard functionality regarding users
and groups management.
It helps creating well-defined user roles and associating them to users.
It can become very hard to maintain a large number of user profiles over time,
juggling with many technical groups. For this purpose, this module will help
you to:
* define functional roles by aggregating low-level groups,
* set user accounts with the predefined roles (roles are cumulative),
* update groups of all relevant user accounts (all at once),
* ensure that user accounts will have the groups defined in their roles
(nothing more, nothing less). In other words, you can not set groups
manually on a user as long as there is roles configured on it,
* activate/deactivate roles depending on the date (useful to plan holidays, etc)
* get a quick overview of roles and the related user accounts.
That way you make clear the different responsabilities within a company, and
are able to add and update user accounts in a scalable and reliable way.
Configuration Configuration
============= =============
To configure this module, you need to go to *Configuration / Users / Roles*,
and create a new role. From there, you can add groups to compose your role,
and then associate users to it.
You can also define default roles for a new user by editing the user called
"Default User".
Roles:
.. image:: /base_user_role/static/description/roles.png
Add groups:
.. image:: /base_user_role/static/description/role_groups.png
Add users (with dates or not):
.. image:: /base_user_role/static/description/role_users.png
Bug Tracker Bug Tracker
=========== ===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/server-backend/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.
Credits Credits
======= =======
Images
------
* Oxygen Team: `Icon <http://www.iconarchive.com/show/oxygen-icons-by-oxygen-icons.org/Actions-user-group-new-icon.html>`_ (LGPL)
Contributors Contributors
------------ ------------
* Sébastien Alix <sebastien.alix@osiell.com>
* Duc, Dao Dong <duc.dd@komit-consulting.com> (https://komit-consulting.com)
Do not contact contributors directly about support or help with technical issues.
Maintainer Maintainer
---------- ----------

5
base_user_role/__manifest__.py

@ -3,11 +3,11 @@
{ {
'name': 'User roles', 'name': 'User roles',
'version': '11.0.1.0.1',
'version': '12.0.1.0.0',
'category': 'Tools', 'category': 'Tools',
'author': 'ABF OSIELL, Odoo Community Association (OCA)', 'author': 'ABF OSIELL, Odoo Community Association (OCA)',
'license': 'AGPL-3', 'license': 'AGPL-3',
'maintainer': 'ABF OSIELL',
'maintainers': ['ABF OSIELL', 'jcdrubay'],
'website': 'http://www.osiell.com', 'website': 'http://www.osiell.com',
'depends': [ 'depends': [
'base', 'base',
@ -20,5 +20,4 @@
'views/user.xml', 'views/user.xml',
], ],
'installable': True, 'installable': True,
'auto_install': False,
} }

12
base_user_role/models/role.py

@ -19,14 +19,16 @@ class ResUsersRole(models.Model):
readonly=True, string="Associated group") readonly=True, string="Associated group")
line_ids = fields.One2many( line_ids = fields.One2many(
comodel_name='res.users.role.line', comodel_name='res.users.role.line',
inverse_name='role_id', string="Users")
inverse_name='role_id', string="Role lines")
user_ids = fields.One2many( user_ids = fields.One2many(
comodel_name='res.users', string="Users",
comodel_name='res.users', string="Users list",
compute='_compute_user_ids') compute='_compute_user_ids')
group_category_id = fields.Many2one( group_category_id = fields.Many2one(
related='group_id.category_id', related='group_id.category_id',
default=lambda cls: cls.env.ref( default=lambda cls: cls.env.ref(
'base_user_role.ir_module_category_role').id)
'base_user_role.ir_module_category_role').id,
string="Associated category",
help="Associated group's category")
@api.multi @api.multi
@api.depends('line_ids.user_id') @api.depends('line_ids.user_id')
@ -86,11 +88,11 @@ class ResUsersRoleLine(models.Model):
for role_line in self: for role_line in self:
role_line.is_enabled = True role_line.is_enabled = True
if role_line.date_from: if role_line.date_from:
date_from = fields.Date.from_string(role_line.date_from)
date_from = role_line.date_from
if date_from > today: if date_from > today:
role_line.is_enabled = False role_line.is_enabled = False
if role_line.date_to: if role_line.date_to:
date_to = fields.Date.from_string(role_line.date_to)
date_to = role_line.date_to
if today > date_to: if today > date_to:
role_line.is_enabled = False role_line.is_enabled = False

18
base_user_role/readme/CONFIGURE.rst

@ -0,0 +1,18 @@
To configure this module, you need to go to *Configuration / Users / Roles*,
and create a new role. From there, you can add groups to compose your role,
and then associate users to it.
You can also define default roles for a new user by editing the user called
"Default User".
Roles:
.. image:: /base_user_role/static/description/roles.png
Add groups:
.. image:: /base_user_role/static/description/role_groups.png
Add users (with dates or not):
.. image:: /base_user_role/static/description/role_users.png

5
base_user_role/readme/CONTRIBUTORS.rst

@ -0,0 +1,5 @@
* Sébastien Alix <sebastien.alix@osiell.com>
* Duc, Dao Dong <duc.dd@komit-consulting.com> (https://komit-consulting.com)
* Jean-Charles Drubay <jc@komit-consulting.com> (https://komit-consulting.com)
Do not contact contributors directly about support or help with technical issues.

4
base_user_role/readme/CREDITS.rst

@ -0,0 +1,4 @@
Images
------
* Oxygen Team: `Icon <http://www.iconarchive.com/show/oxygen-icons-by-oxygen-icons.org/Actions-user-group-new-icon.html>`_ (LGPL)

19
base_user_role/readme/DESCRIPTION.rst

@ -0,0 +1,19 @@
This module was written to extend the standard functionality regarding users
and groups management.
It helps creating well-defined user roles and associating them to users.
It can become very hard to maintain a large number of user profiles over time,
juggling with many technical groups. For this purpose, this module will help
you to:
* define functional roles by aggregating low-level groups,
* set user accounts with the predefined roles (roles are cumulative),
* update groups of all relevant user accounts (all at once),
* ensure that user accounts will have the groups defined in their roles
(nothing more, nothing less). In other words, you can not set groups
manually on a user as long as there is roles configured on it,
* activate/deactivate roles depending on the date (useful to plan holidays, etc)
* get a quick overview of roles and the related user accounts.
That way you make clear the different responsabilities within a company, and
are able to add and update user accounts in a scalable and reliable way.

4
base_user_role/readme/ROADMAP.rst

@ -0,0 +1,4 @@
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/server-backend/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

13
base_user_role/readme/USAGE.rst

@ -0,0 +1,13 @@
[ 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:
.. image:: /base_user_role/static/description/user_form.png

BIN
base_user_role/static/description/user_form.png

After

Width: 877  |  Height: 338  |  Size: 22 KiB

5
base_user_role/tests/test_user_role.py

@ -28,13 +28,16 @@ class TestUserRole(TransactionCase):
self.role1_id = self.role_model.create(vals) self.role1_id = self.role_model.create(vals)
# ROLE_2 # ROLE_2
# Must have group_user in order to have sufficient groups. Check:
# github.com/odoo/odoo/commit/c3717f3018ce0571aa41f70da4262cc946d883b4
self.group_multi_currency_id = self.env.ref( self.group_multi_currency_id = self.env.ref(
'base.group_multi_currency') 'base.group_multi_currency')
self.group_settings_id = self.env.ref('base.group_system') self.group_settings_id = self.env.ref('base.group_system')
vals = { vals = {
'name': "ROLE_2", 'name': "ROLE_2",
'implied_ids': [ 'implied_ids': [
(6, 0, [self.group_multi_currency_id.id,
(6, 0, [self.group_user_id.id,
self.group_multi_currency_id.id,
self.group_settings_id.id])], self.group_settings_id.id])],
} }
self.role2_id = self.role_model.create(vals) self.role2_id = self.role_model.create(vals)

Loading…
Cancel
Save