From 893d3bd8a58470c3f8a808b3f01b8435c02c1972 Mon Sep 17 00:00:00 2001 From: Bhavesh Heliconia Date: Mon, 17 Feb 2025 16:41:17 +0530 Subject: [PATCH] [MIG] document_page_access_group: Migration to 18.0 --- document_page_access_group/README.rst | 31 ++++++++++--------- document_page_access_group/__manifest__.py | 2 +- .../17.0.1.1.0/noupdate_changes.xml | 8 ----- .../migrations/17.0.1.1.0/post-migration.py | 12 ------- .../models/document_page.py | 6 ++-- .../readme/CONTRIBUTORS.md | 2 ++ .../security/security.xml | 4 +-- .../static/description/index.html | 13 +++++--- document_page_access_group/tests/common.py | 7 +++-- .../tests/test_document_page_access_group.py | 3 +- 10 files changed, 40 insertions(+), 48 deletions(-) delete mode 100644 document_page_access_group/migrations/17.0.1.1.0/noupdate_changes.xml delete mode 100644 document_page_access_group/migrations/17.0.1.1.0/post-migration.py diff --git a/document_page_access_group/README.rst b/document_page_access_group/README.rst index e1da0deb..5044ea3e 100644 --- a/document_page_access_group/README.rst +++ b/document_page_access_group/README.rst @@ -17,13 +17,13 @@ Document Page Access Group :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github - :target: https://github.com/OCA/knowledge/tree/17.0/document_page_access_group + :target: https://github.com/OCA/knowledge/tree/18.0/document_page_access_group :alt: OCA/knowledge .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/knowledge-17-0/knowledge-17-0-document_page_access_group + :target: https://translation.odoo-community.org/projects/knowledge-18-0/knowledge-18-0-document_page_access_group :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=17.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=18.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -42,11 +42,10 @@ Usage To select the users that have access to a given document page you need to open a document, go to the 'Security' tab and you have 3 options: -- Select a group: Only users with those groups will be able to see the - page. -- Select any user: Only the selected users will be able to see the - page. -- Do not select group or user: All users will be able to see the page. +- Select a group: Only users with those groups will be able to see the + page. +- Select any user: Only the selected users will be able to see the page. +- Do not select group or user: All users will be able to see the page. Bug Tracker =========== @@ -54,7 +53,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -69,12 +68,16 @@ Authors Contributors ------------ -- Manuel Regidor -- Alberto Martínez +- Manuel Regidor +- Alberto Martínez -- ``Tecnativa ``\ \_: +- ``Tecnativa ``\ \_: - - Víctor Martínez + - Víctor Martínez + +- `Heliconia Solutions Pvt. Ltd. `__ + + - Bhavesh Heliconia Maintainers ----------- @@ -89,6 +92,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/knowledge `_ project on GitHub. +This module is part of the `OCA/knowledge `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/document_page_access_group/__manifest__.py b/document_page_access_group/__manifest__.py index a91bdd01..b0aed75f 100644 --- a/document_page_access_group/__manifest__.py +++ b/document_page_access_group/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Document Page Access Group", "summary": "Choose groups to access document pages", - "version": "17.0.2.0.0", + "version": "18.0.1.0.0", "category": "document_knowledge", "website": "https://github.com/OCA/knowledge", "author": "Sygel, Odoo Community Association (OCA)", diff --git a/document_page_access_group/migrations/17.0.1.1.0/noupdate_changes.xml b/document_page_access_group/migrations/17.0.1.1.0/noupdate_changes.xml deleted file mode 100644 index 185dcbb3..00000000 --- a/document_page_access_group/migrations/17.0.1.1.0/noupdate_changes.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - ['|', ('groups_id', 'in', [g.id for g in user.groups_id]), '|', ('user_ids', 'in', [user.id]), '&', ('groups_id', '=', False), ('user_ids', '=', False)] - - diff --git a/document_page_access_group/migrations/17.0.1.1.0/post-migration.py b/document_page_access_group/migrations/17.0.1.1.0/post-migration.py deleted file mode 100644 index 8c7aacd6..00000000 --- a/document_page_access_group/migrations/17.0.1.1.0/post-migration.py +++ /dev/null @@ -1,12 +0,0 @@ -# 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): - openupgrade.load_data( - env, - "document_page_access_group", - "migrations/17.0.1.1.0/noupdate_changes.xml", - ) diff --git a/document_page_access_group/models/document_page.py b/document_page_access_group/models/document_page.py index 84279501..58895c7f 100644 --- a/document_page_access_group/models/document_page.py +++ b/document_page_access_group/models/document_page.py @@ -2,7 +2,7 @@ # Copyright 2024 Tecnativa - Víctor Martínez # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import _, api, fields, models +from odoo import api, fields, models from odoo.exceptions import UserError @@ -15,5 +15,7 @@ class DocumentPage(models.Model): @api.constrains("groups_id", "user_ids") def check_document_page_groups_users(self): for _item in self.filtered(lambda x: x.groups_id and x.user_ids): - raise UserError(_("You cannot set groups and users at the same time.")) + raise UserError( + self.env._("You cannot set groups and users at the same time.") + ) return True diff --git a/document_page_access_group/readme/CONTRIBUTORS.md b/document_page_access_group/readme/CONTRIBUTORS.md index 7ad918f3..4ddc3399 100644 --- a/document_page_access_group/readme/CONTRIBUTORS.md +++ b/document_page_access_group/readme/CONTRIBUTORS.md @@ -3,3 +3,5 @@ * `Tecnativa `_: * Víctor Martínez +- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io) + - Bhavesh Heliconia diff --git a/document_page_access_group/security/security.xml b/document_page_access_group/security/security.xml index c7e20cbf..cf3aaea7 100644 --- a/document_page_access_group/security/security.xml +++ b/document_page_access_group/security/security.xml @@ -8,7 +8,7 @@ [(1, '=', 1)] diff --git a/document_page_access_group/static/description/index.html b/document_page_access_group/static/description/index.html index 5a8395f5..aaceaee1 100644 --- a/document_page_access_group/static/description/index.html +++ b/document_page_access_group/static/description/index.html @@ -369,7 +369,7 @@ ul.auto-toc { !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:28e06c90139270717bf9f3fbe04145a72fed721a256eb4d526ee229beaf1cc69 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/knowledge Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/knowledge Translate me on Weblate Try me on Runboat

This module allows to select which users groups have access to the document pages.

Table of contents

@@ -392,8 +392,7 @@ to open a document, go to the ‘Security’ tab and you have 3 options:

  • Select a group: Only users with those groups will be able to see the page.
  • -
  • Select any user: Only the selected users will be able to see the -page.
  • +
  • Select any user: Only the selected users will be able to see the page.
  • Do not select group or user: All users will be able to see the page.
@@ -402,7 +401,7 @@ page.

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -422,6 +421,10 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
  • Víctor Martínez
  • +
  • Heliconia Solutions Pvt. Ltd.
      +
    • Bhavesh Heliconia
    • +
    +
  • @@ -433,7 +436,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

    -

    This module is part of the OCA/knowledge project on GitHub.

    +

    This module is part of the OCA/knowledge project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/document_page_access_group/tests/common.py b/document_page_access_group/tests/common.py index 1f92d881..4feba377 100644 --- a/document_page_access_group/tests/common.py +++ b/document_page_access_group/tests/common.py @@ -1,4 +1,5 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import Command from odoo.tests import new_test_user from odoo.addons.base.tests.common import BaseCommon @@ -17,7 +18,7 @@ class TestDocumentPageAccessGroupBase(BaseCommon): login="test-manager-user", groups="document_knowledge.group_document_user", ) - cls.manager_user.write({"groups_id": [(4, cls.group.id)]}) + cls.manager_user.write({"groups_id": [Command.link(cls.group.id)]}) cls.public_page = cls.env["document.page"].create( {"name": "Public Page", "type": "content"} ) @@ -25,13 +26,13 @@ class TestDocumentPageAccessGroupBase(BaseCommon): { "name": "Knowledge Page", "type": "content", - "groups_id": [(6, 0, [cls.group.id])], + "groups_id": [Command.set([cls.group.id])], } ) cls.user_page = cls.env["document.page"].create( { "name": "User Page (basic user)", "type": "content", - "user_ids": [(6, 0, [cls.user.id])], + "user_ids": [Command.set([cls.user.id])], } ) diff --git a/document_page_access_group/tests/test_document_page_access_group.py b/document_page_access_group/tests/test_document_page_access_group.py index 3a1ec8c4..c687244e 100644 --- a/document_page_access_group/tests/test_document_page_access_group.py +++ b/document_page_access_group/tests/test_document_page_access_group.py @@ -1,4 +1,5 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import Command from odoo.exceptions import UserError from odoo.tests.common import users @@ -8,7 +9,7 @@ from .common import TestDocumentPageAccessGroupBase class TestDocumentPageAccessGroup(TestDocumentPageAccessGroupBase): def test_page_access_constrains(self): with self.assertRaises(UserError): - self.knowledge_page.write({"user_ids": [(6, 0, [self.user.id])]}) + self.knowledge_page.write({"user_ids": [Command.set([self.user.id])]}) @users("test-user") def test_page_access_01(self):