mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[MIG] base_user_role: Migration to 15.0
This commit is contained in:
committed by
Bert Van Groenendael
parent
13f793c4c8
commit
bcd732d3b8
@@ -14,16 +14,16 @@ User roles
|
|||||||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||||
:alt: License: LGPL-3
|
:alt: License: LGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github
|
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github
|
||||||
:target: https://github.com/OCA/server-backend/tree/14.0/base_user_role
|
:target: https://github.com/OCA/server-backend/tree/15.0/base_user_role
|
||||||
:alt: OCA/server-backend
|
:alt: OCA/server-backend
|
||||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||||
:target: https://translation.odoo-community.org/projects/server-backend-14-0/server-backend-14-0-base_user_role
|
:target: https://translation.odoo-community.org/projects/server-backend-15-0/server-backend-15-0-base_user_role
|
||||||
:alt: Translate me on Weblate
|
:alt: Translate me on Weblate
|
||||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||||
:target: https://runbot.odoo-community.org/runbot/253/14.0
|
:target: https://runbot.odoo-community.org/runbot/253/15.0
|
||||||
:alt: Try me on Runbot
|
:alt: Try me on Runbot
|
||||||
|
|
||||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||||
|
|
||||||
This module was written to extend the standard functionality regarding users
|
This module was written to extend the standard functionality regarding users
|
||||||
and groups management.
|
and groups management.
|
||||||
@@ -150,8 +150,8 @@ promote its widespread use.
|
|||||||
|
|
||||||
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
|
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
|
||||||
|
|
||||||
|maintainer-sebalix| |maintainer-jcdrubay| |maintainer-novawish|
|
|maintainer-sebalix| |maintainer-jcdrubay| |maintainer-novawish|
|
||||||
|
|
||||||
This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/14.0/base_user_role>`_ project on GitHub.
|
This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/15.0/base_user_role>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "User roles",
|
"name": "User roles",
|
||||||
"version": "14.0.2.1.1",
|
"version": "15.0.0.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",
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
from . import role
|
from . import role
|
||||||
from . import user
|
from . import user
|
||||||
|
from . import res_groups
|
||||||
|
|||||||
9
base_user_role/models/res_groups.py
Normal file
9
base_user_role/models/res_groups.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class ResGroups(models.Model):
|
||||||
|
_inherit = "res.groups"
|
||||||
|
|
||||||
|
view_access = fields.Many2many(
|
||||||
|
groups="base.group_system",
|
||||||
|
)
|
||||||
@@ -44,11 +44,25 @@ class ResUsersRole(models.Model):
|
|||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
|
# Run method as super user to avoid problems with new groups creations
|
||||||
|
# by "Administrator/Access Right"
|
||||||
|
is_access_rights = self.env.user.has_group(
|
||||||
|
"base.group_erp_manager",
|
||||||
|
)
|
||||||
|
if self._name == "res.users.role" and is_access_rights:
|
||||||
|
self = self.sudo()
|
||||||
new_record = super(ResUsersRole, self).create(vals)
|
new_record = super(ResUsersRole, self).create(vals)
|
||||||
new_record.update_users()
|
new_record.update_users()
|
||||||
return new_record
|
return new_record
|
||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
|
# Run method as super user to avoid problems with new groups creations
|
||||||
|
# by "Administrator/Access Right"
|
||||||
|
is_access_rights = self.env.user.has_group(
|
||||||
|
"base.group_erp_manager",
|
||||||
|
)
|
||||||
|
if self._name == "res.users.role" and is_access_rights:
|
||||||
|
self = self.sudo()
|
||||||
# Workaround to solve issue with broken code in odoo that clear the cache
|
# Workaround to solve issue with broken code in odoo that clear the cache
|
||||||
# during the write: see odoo/addons/base/models/res_users.py#L226
|
# during the write: see odoo/addons/base/models/res_users.py#L226
|
||||||
groups_vals = {}
|
groups_vals = {}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
To configure this module, you need to go to *Configuration / Users / Roles*,
|
To configure this module, you need to go to *Settings / Users / Roles*,
|
||||||
and create a new role. From there, you can add groups to compose your role,
|
and create a new role. From there, you can add groups to compose your role,
|
||||||
and then associate users to it.
|
and then associate users to it.
|
||||||
|
|
||||||
@@ -7,18 +7,18 @@ You can also define default roles for a new user by editing the user called
|
|||||||
|
|
||||||
Roles:
|
Roles:
|
||||||
|
|
||||||
.. figure:: /OCA/server-backend/12.0/base_user_role/static/description/roles.png
|
.. figure:: /OCA/server-backend/15.0/base_user_role/static/description/roles.png
|
||||||
:width: 80 %
|
:width: 80 %
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
Add groups:
|
Add groups:
|
||||||
|
|
||||||
.. figure:: /OCA/server-backend/12.0/base_user_role/static/description/role_groups.png
|
.. figure:: /OCA/server-backend/15.0/base_user_role/static/description/role_groups.png
|
||||||
:width: 80 %
|
:width: 80 %
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
Add users (with dates or not):
|
Add users (with dates or not):
|
||||||
|
|
||||||
.. figure:: /OCA/server-backend/12.0/base_user_role/static/description/role_users.png
|
.. figure:: /OCA/server-backend/15.0/base_user_role/static/description/role_users.png
|
||||||
:width: 80 %
|
:width: 80 %
|
||||||
:align: center
|
:align: center
|
||||||
|
|||||||
@@ -4,5 +4,6 @@
|
|||||||
* Alan Ramos <alan.ramos@jarsa.com.mx> (https://www.jarsa.com.mx)
|
* Alan Ramos <alan.ramos@jarsa.com.mx> (https://www.jarsa.com.mx)
|
||||||
* Harald Panten <harald.panten@sygel.es>
|
* Harald Panten <harald.panten@sygel.es>
|
||||||
* Kevin Khao <kevin.khao@akretion.com>
|
* Kevin Khao <kevin.khao@akretion.com>
|
||||||
|
* Tatiana Deribina <tatiana.deribina@sprintit.fi> (https://sprintit.fi)
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|||||||
Reference in New Issue
Block a user