diff --git a/document_page_access_group/README.rst b/document_page_access_group/README.rst new file mode 100644 index 00000000..173059a1 --- /dev/null +++ b/document_page_access_group/README.rst @@ -0,0 +1,91 @@ +========================== +Document Page Access Group +========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c85275090dedd45d4b073c18899cbebce88d61f658db956fc820c3f590d32076 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :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 + :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 + :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 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to select which users groups have access to the +document pages. + +**Table of contents** + +.. contents:: + :local: + +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 select which groups +will have access. + +Only users that belong to the 'document_knowledge / Manager' group can +manage access groups to documents. + +If no groups are selected in a document, all users that can access +document pages can access this document. + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Sygel + +Contributors +------------ + +- Manuel Regidor +- Alberto Martínez + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/document_page_access_group/__init__.py b/document_page_access_group/__init__.py new file mode 100644 index 00000000..18143cb9 --- /dev/null +++ b/document_page_access_group/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2022 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/document_page_access_group/__manifest__.py b/document_page_access_group/__manifest__.py new file mode 100644 index 00000000..bd72b89c --- /dev/null +++ b/document_page_access_group/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2022 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Document Page Access Group", + "summary": "Choose groups to access document pages", + "version": "17.0.1.0.0", + "category": "document_knowledge", + "website": "https://github.com/OCA/knowledge", + "author": "Sygel, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "document_page", + "document_knowledge", + ], + "data": ["views/document_page.xml", "security/security.xml"], +} diff --git a/document_page_access_group/i18n/document_page_access_group.pot b/document_page_access_group/i18n/document_page_access_group.pot new file mode 100644 index 00000000..13249f5a --- /dev/null +++ b/document_page_access_group/i18n/document_page_access_group.pot @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_access_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: document_page_access_group +#: model:ir.model.fields,field_description:document_page_access_group.field_document_page__display_name +msgid "Display Name" +msgstr "" + +#. module: document_page_access_group +#: model:ir.model,name:document_page_access_group.model_document_page +msgid "Document Page" +msgstr "" + +#. module: document_page_access_group +#: model:ir.model.fields,field_description:document_page_access_group.field_document_page__groups_id +msgid "Groups" +msgstr "" + +#. module: document_page_access_group +#: model:ir.model.fields,field_description:document_page_access_group.field_document_page__id +msgid "ID" +msgstr "" + +#. module: document_page_access_group +#: model:ir.model.fields,field_description:document_page_access_group.field_document_page____last_update +msgid "Last Modified on" +msgstr "" + +#. module: document_page_access_group +#: model_terms:ir.ui.view,arch_db:document_page_access_group.document_page_access_group_view_wiki_form +msgid "Security" +msgstr "" diff --git a/document_page_access_group/i18n/es.po b/document_page_access_group/i18n/es.po new file mode 100644 index 00000000..97896a2f --- /dev/null +++ b/document_page_access_group/i18n/es.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_access_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-06-05 13:08+0000\n" +"Last-Translator: luis-ron \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: document_page_access_group +#: model:ir.model.fields,field_description:document_page_access_group.field_document_page__display_name +msgid "Display Name" +msgstr "Nombre mostrado" + +#. module: document_page_access_group +#: model:ir.model,name:document_page_access_group.model_document_page +msgid "Document Page" +msgstr "Página de documento" + +#. module: document_page_access_group +#: model:ir.model.fields,field_description:document_page_access_group.field_document_page__groups_id +msgid "Groups" +msgstr "Grupos" + +#. module: document_page_access_group +#: model:ir.model.fields,field_description:document_page_access_group.field_document_page__id +msgid "ID" +msgstr "ID" + +#. module: document_page_access_group +#: model:ir.model.fields,field_description:document_page_access_group.field_document_page____last_update +msgid "Last Modified on" +msgstr "Última modificación el" + +#. module: document_page_access_group +#: model_terms:ir.ui.view,arch_db:document_page_access_group.document_page_access_group_view_wiki_form +msgid "Security" +msgstr "Seguridad" diff --git a/document_page_access_group/i18n/it.po b/document_page_access_group/i18n/it.po new file mode 100644 index 00000000..0457799d --- /dev/null +++ b/document_page_access_group/i18n/it.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_access_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-12-29 02:09+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.14.1\n" + +#. module: document_page_access_group +#: model:ir.model.fields,field_description:document_page_access_group.field_document_page__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: document_page_access_group +#: model:ir.model,name:document_page_access_group.model_document_page +msgid "Document Page" +msgstr "Pagina documento" + +#. module: document_page_access_group +#: model:ir.model.fields,field_description:document_page_access_group.field_document_page__groups_id +msgid "Groups" +msgstr "Gruppi" + +#. module: document_page_access_group +#: model:ir.model.fields,field_description:document_page_access_group.field_document_page__id +msgid "ID" +msgstr "ID" + +#. module: document_page_access_group +#: model:ir.model.fields,field_description:document_page_access_group.field_document_page____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: document_page_access_group +#: model_terms:ir.ui.view,arch_db:document_page_access_group.document_page_access_group_view_wiki_form +msgid "Security" +msgstr "Sicurezza" diff --git a/document_page_access_group/models/__init__.py b/document_page_access_group/models/__init__.py new file mode 100644 index 00000000..5aedcf2a --- /dev/null +++ b/document_page_access_group/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2022 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import document_page diff --git a/document_page_access_group/models/document_page.py b/document_page_access_group/models/document_page.py new file mode 100644 index 00000000..e8ff91e9 --- /dev/null +++ b/document_page_access_group/models/document_page.py @@ -0,0 +1,10 @@ +# Copyright 2022 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class DocumentPage(models.Model): + _inherit = "document.page" + + groups_id = fields.Many2many(comodel_name="res.groups", string="Groups") diff --git a/document_page_access_group/pyproject.toml b/document_page_access_group/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/document_page_access_group/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/document_page_access_group/readme/CONTRIBUTORS.md b/document_page_access_group/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..8dc3b6ac --- /dev/null +++ b/document_page_access_group/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Manuel Regidor \<\> +- Alberto Martínez \<\> diff --git a/document_page_access_group/readme/DESCRIPTION.md b/document_page_access_group/readme/DESCRIPTION.md new file mode 100644 index 00000000..ecf456b6 --- /dev/null +++ b/document_page_access_group/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module allows to select which users groups have access to the +document pages. diff --git a/document_page_access_group/readme/USAGE.md b/document_page_access_group/readme/USAGE.md new file mode 100644 index 00000000..82e3cf74 --- /dev/null +++ b/document_page_access_group/readme/USAGE.md @@ -0,0 +1,9 @@ +To select the users that have access to a given document page you need +to open a document, go to the 'Security' tab and select which groups +will have access. + +Only users that belong to the 'document_knowledge / Manager' group can +manage access groups to documents. + +If no groups are selected in a document, all users that can access +document pages can access this document. diff --git a/document_page_access_group/security/security.xml b/document_page_access_group/security/security.xml new file mode 100644 index 00000000..b35fa135 --- /dev/null +++ b/document_page_access_group/security/security.xml @@ -0,0 +1,27 @@ + + + + + Document Page Access + + + + ['|', ('groups_id', '=', False), ('groups_id', 'in', [g.id for g in user.groups_id])] + + + Document Page Full Access + + + + [(1, '=', 1)] + + diff --git a/document_page_access_group/static/description/icon.png b/document_page_access_group/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/document_page_access_group/static/description/icon.png differ diff --git a/document_page_access_group/static/description/index.html b/document_page_access_group/static/description/index.html new file mode 100644 index 00000000..9f108ddd --- /dev/null +++ b/document_page_access_group/static/description/index.html @@ -0,0 +1,434 @@ + + + + + + +Document Page Access Group + + + +
+

Document Page Access Group

+ + +

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

+ +
+

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 select which groups +will have access.

+

Only users that belong to the ‘document_knowledge / Manager’ group can +manage access groups to documents.

+

If no groups are selected in a document, all users that can access +document pages can access this document.

+
+
+

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Sygel
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

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

+
+
+
+ + diff --git a/document_page_access_group/tests/__init__.py b/document_page_access_group/tests/__init__.py new file mode 100644 index 00000000..d2acbb67 --- /dev/null +++ b/document_page_access_group/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_document_page_access_group 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 new file mode 100644 index 00000000..d0e0ccbd --- /dev/null +++ b/document_page_access_group/tests/test_document_page_access_group.py @@ -0,0 +1,29 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo.exceptions import UserError +from odoo.tests import common + + +class TestDocumentPageAccessGroup(common.TransactionCase): + def setUp(self): + super().setUp() + self.document_user_group = self.browse_ref( + "document_knowledge.group_document_user" + ).id + self.test_group = self.browse_ref("base.group_erp_manager").id + self.user_id = self.env["res.users"].create( + { + "name": "user", + "login": "user_login", + "email": "user_email", + "groups_id": [(4, self.document_user_group)], + } + ) + self.page = self.env["document.page"].create( + {"name": "Page 1", "type": "content"} + ) + + def test_page_access(self): + self.assertIsNone(self.page.with_user(self.user_id).check_access_rule("read")) + self.page.write({"groups_id": [(4, self.test_group)]}) + with self.assertRaises(UserError): + self.page.with_user(self.user_id).check_access_rule("read") diff --git a/document_page_access_group/views/document_page.xml b/document_page_access_group/views/document_page.xml new file mode 100644 index 00000000..b09cba7d --- /dev/null +++ b/document_page_access_group/views/document_page.xml @@ -0,0 +1,21 @@ + + + + + document.page.access.group.view.wiki.form + document.page + + + + + + + + + +