diff --git a/document_page_access_group_user_role/README.rst b/document_page_access_group_user_role/README.rst index da78eeab3e5..8b160bc9fc7 100644 --- a/document_page_access_group_user_role/README.rst +++ b/document_page_access_group_user_role/README.rst @@ -42,7 +42,7 @@ Usage #. Go to `Knowledge / Pages` and create or edit one. #. Set in the "Roles" tab the one we have just created. #. Go back to the role, edit it and add any group(s). -#. The role groups will have been added in the "Security" tab. +#. The role users will have been added in the "Security" tab. Bug Tracker =========== diff --git a/document_page_access_group_user_role/__manifest__.py b/document_page_access_group_user_role/__manifest__.py index 45f5a0fc22c..54a075cb804 100644 --- a/document_page_access_group_user_role/__manifest__.py +++ b/document_page_access_group_user_role/__manifest__.py @@ -4,7 +4,7 @@ "name": "Document Page Access Group User Role", "author": "Tecnativa, Odoo Community Association (OCA)", "website": "https://github.com/OCA/knowledge", - "version": "16.0.1.0.0", + "version": "16.0.1.1.0", "depends": ["document_page_access_group", "base_user_role"], "license": "AGPL-3", "category": "Knowledge", diff --git a/document_page_access_group_user_role/migrations/16.0.1.1.0/post-migration.py b/document_page_access_group_user_role/migrations/16.0.1.1.0/post-migration.py new file mode 100644 index 00000000000..cd6bbf60b77 --- /dev/null +++ b/document_page_access_group_user_role/migrations/16.0.1.1.0/post-migration.py @@ -0,0 +1,12 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + """Pages that had roles should now have the correct users.""" + pages = env["document.page"].sudo().search([("role_ids", "!=", [])]) + for page in pages: + page.role_ids = False + page._compute_user_ids() diff --git a/document_page_access_group_user_role/models/document_page.py b/document_page_access_group_user_role/models/document_page.py index f9bf89cfc3c..a4db0ed05cd 100644 --- a/document_page_access_group_user_role/models/document_page.py +++ b/document_page_access_group_user_role/models/document_page.py @@ -7,7 +7,7 @@ class DocumentPage(models.Model): _inherit = "document.page" - groups_id = fields.Many2many(compute="_compute_groups_id", store=True) + user_ids = fields.Many2many(compute="_compute_user_ids", store=True, readonly=False) role_ids = fields.Many2many( comodel_name="res.users.role", relation="document_page_user_roles_rel", @@ -16,8 +16,8 @@ class DocumentPage(models.Model): string="Roles", ) - @api.depends("role_ids", "role_ids.implied_ids") - def _compute_groups_id(self): - """Create a compute to auto-set all the groups of the related roles.""" + @api.depends("role_ids", "role_ids.users") + def _compute_user_ids(self): + """Create a compute to auto-set all the users of the related roles.""" for item in self: - item.groups_id = item.mapped("role_ids.implied_ids") + item.user_ids += item.mapped("role_ids.users") diff --git a/document_page_access_group_user_role/readme/USAGE.rst b/document_page_access_group_user_role/readme/USAGE.rst index 568c9352f98..4d593dcabd3 100644 --- a/document_page_access_group_user_role/readme/USAGE.rst +++ b/document_page_access_group_user_role/readme/USAGE.rst @@ -2,4 +2,4 @@ #. Go to `Knowledge / Pages` and create or edit one. #. Set in the "Roles" tab the one we have just created. #. Go back to the role, edit it and add any group(s). -#. The role groups will have been added in the "Security" tab. +#. The role users will have been added in the "Security" tab. diff --git a/document_page_access_group_user_role/static/description/index.html b/document_page_access_group_user_role/static/description/index.html index 60c98a6a493..f725f4beb2c 100644 --- a/document_page_access_group_user_role/static/description/index.html +++ b/document_page_access_group_user_role/static/description/index.html @@ -1,4 +1,3 @@ -
@@ -391,7 +390,7 @@