diff --git a/document_page_group/README.rst b/document_page_group/README.rst new file mode 100644 index 00000000000..35a2d8ff209 --- /dev/null +++ b/document_page_group/README.rst @@ -0,0 +1,79 @@ +=================== +Document Page Group +=================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:66053447d3b9de33ad8ea86a718107d908a3d2e2945b788b7f782350e5da299b + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_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_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 define groups on a category. + +**Table of contents** + +.. contents:: + :local: + +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 +------- + +* Creu Blanca + +Contributors +------------ + +- Enric Tobella +- [APSL-Nagarro](https://apsl.tech): + + - Antoni Marroig + +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_group/__init__.py b/document_page_group/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/document_page_group/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/document_page_group/__manifest__.py b/document_page_group/__manifest__.py new file mode 100644 index 00000000000..c352dcf0961 --- /dev/null +++ b/document_page_group/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2019 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Document Page Group", + "summary": """ + Define access groups on documents""", + "version": "17.0.1.0.0", + "license": "AGPL-3", + "author": "Creu Blanca,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/knowledge", + "depends": ["document_page"], + "data": ["security/document_page_security.xml", "views/document_page.xml"], +} diff --git a/document_page_group/i18n/document_page_group.pot b/document_page_group/i18n/document_page_group.pot new file mode 100644 index 00000000000..9f2e7f11dee --- /dev/null +++ b/document_page_group/i18n/document_page_group.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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_group +#: model:ir.model,name:document_page_group.model_document_page +msgid "Document Page" +msgstr "" + +#. module: document_page_group +#: model:ir.model.fields,field_description:document_page_group.field_document_page__group_ids +msgid "Group" +msgstr "" + +#. module: document_page_group +#: model:ir.model.fields,help:document_page_group.field_document_page__direct_group_ids +msgid "Set the groups that can view this category and its childs" +msgstr "" + +#. module: document_page_group +#: model:ir.model.fields,field_description:document_page_group.field_document_page__direct_group_ids +msgid "Visible to" +msgstr "" diff --git a/document_page_group/i18n/es.po b/document_page_group/i18n/es.po new file mode 100644 index 00000000000..66fa93a5477 --- /dev/null +++ b/document_page_group/i18n/es.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-01-15 16:23+0000\n" +"Last-Translator: Enric Tobella \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 3.10\n" + +#. module: document_page_group +#: model:ir.model,name:document_page_group.model_document_page +msgid "Document Page" +msgstr "Página del documento" + +#. module: document_page_group +#: model:ir.model.fields,field_description:document_page_group.field_document_page__group_ids +msgid "Group" +msgstr "Grupo" + +#. module: document_page_group +#: model:ir.model.fields,help:document_page_group.field_document_page__direct_group_ids +msgid "Set the groups that can view this category and its childs" +msgstr "Definir los grupos que puede ver una categoría y sus hijos" + +#. module: document_page_group +#: model:ir.model.fields,field_description:document_page_group.field_document_page__direct_group_ids +msgid "Visible to" +msgstr "Visible para" diff --git a/document_page_group/i18n/hr.po b/document_page_group/i18n/hr.po new file mode 100644 index 00000000000..dcac7f3ef77 --- /dev/null +++ b/document_page_group/i18n/hr.po @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-02-13 13:23+0000\n" +"Last-Translator: Bole \n" +"Language-Team: none\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"X-Generator: Weblate 4.14.1\n" + +#. module: document_page_group +#: model:ir.model,name:document_page_group.model_document_page +msgid "Document Page" +msgstr "Stranica dokumenta" + +#. module: document_page_group +#: model:ir.model.fields,field_description:document_page_group.field_document_page__group_ids +msgid "Group" +msgstr "Grupa" + +#. module: document_page_group +#: model:ir.model.fields,help:document_page_group.field_document_page__direct_group_ids +msgid "Set the groups that can view this category and its childs" +msgstr "Postavite grupe koje mogu vidjeti ovu kategoriju i njoj podređene" + +#. module: document_page_group +#: model:ir.model.fields,field_description:document_page_group.field_document_page__direct_group_ids +msgid "Visible to" +msgstr "Vidljivo za" diff --git a/document_page_group/i18n/it.po b/document_page_group/i18n/it.po new file mode 100644 index 00000000000..44c1f7ac494 --- /dev/null +++ b/document_page_group/i18n/it.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-06-23 09: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.17\n" + +#. module: document_page_group +#: model:ir.model,name:document_page_group.model_document_page +msgid "Document Page" +msgstr "Pagina documento" + +#. module: document_page_group +#: model:ir.model.fields,field_description:document_page_group.field_document_page__group_ids +msgid "Group" +msgstr "Gruppo" + +#. module: document_page_group +#: model:ir.model.fields,help:document_page_group.field_document_page__direct_group_ids +msgid "Set the groups that can view this category and its childs" +msgstr "Imposta i gruppi che possono visualizzare questa categoria e le figlie" + +#. module: document_page_group +#: model:ir.model.fields,field_description:document_page_group.field_document_page__direct_group_ids +msgid "Visible to" +msgstr "Visibile a" diff --git a/document_page_group/i18n/pt.po b/document_page_group/i18n/pt.po new file mode 100644 index 00000000000..c7ff192bce7 --- /dev/null +++ b/document_page_group/i18n/pt.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-02-28 21:33+0000\n" +"Last-Translator: Peter Romão \n" +"Language-Team: none\n" +"Language: pt\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_group +#: model:ir.model,name:document_page_group.model_document_page +msgid "Document Page" +msgstr "Página do documento" + +#. module: document_page_group +#: model:ir.model.fields,field_description:document_page_group.field_document_page__group_ids +msgid "Group" +msgstr "Grupo" + +#. module: document_page_group +#: model:ir.model.fields,help:document_page_group.field_document_page__direct_group_ids +msgid "Set the groups that can view this category and its childs" +msgstr "Definir os grupos que podem exibir esta categoria e seus descendentes" + +#. module: document_page_group +#: model:ir.model.fields,field_description:document_page_group.field_document_page__direct_group_ids +msgid "Visible to" +msgstr "Visível para" diff --git a/document_page_group/i18n/sl.po b/document_page_group/i18n/sl.po new file mode 100644 index 00000000000..237d34ef6db --- /dev/null +++ b/document_page_group/i18n/sl.po @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-03-21 11:13+0000\n" +"Last-Translator: Matjaz Mozetic \n" +"Language-Team: none\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" +"%100==4 ? 2 : 3;\n" +"X-Generator: Weblate 3.10\n" + +#. module: document_page_group +#: model:ir.model,name:document_page_group.model_document_page +msgid "Document Page" +msgstr "Stran dokumenta" + +#. module: document_page_group +#: model:ir.model.fields,field_description:document_page_group.field_document_page__group_ids +msgid "Group" +msgstr "Skupina" + +#. module: document_page_group +#: model:ir.model.fields,help:document_page_group.field_document_page__direct_group_ids +msgid "Set the groups that can view this category and its childs" +msgstr "Nastavi skupine z vpogledom v to kategorijo in njej podrejenim" + +#. module: document_page_group +#: model:ir.model.fields,field_description:document_page_group.field_document_page__direct_group_ids +msgid "Visible to" +msgstr "Vidno za" diff --git a/document_page_group/models/__init__.py b/document_page_group/models/__init__.py new file mode 100644 index 00000000000..427be24e72a --- /dev/null +++ b/document_page_group/models/__init__.py @@ -0,0 +1 @@ +from . import document_page diff --git a/document_page_group/models/document_page.py b/document_page_group/models/document_page.py new file mode 100644 index 00000000000..3117af34d05 --- /dev/null +++ b/document_page_group/models/document_page.py @@ -0,0 +1,34 @@ +# Copyright 2019 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class DocumentPage(models.Model): + _inherit = "document.page" + + group_ids = fields.Many2many( + "res.groups", + store=True, + recursive=True, + relation="document_page_direct_group", + column1="document_page_id", + column2="group_id", + compute="_compute_group_ids", + ) + direct_group_ids = fields.Many2many( + "res.groups", + string="Visible to", + help="Set the groups that can view this category and its childs", + relation="document_page_group", + column1="document_page_id", + column2="group_id", + ) + + @api.depends("direct_group_ids", "parent_id", "parent_id.group_ids") + def _compute_group_ids(self): + for record in self: + groups = record.direct_group_ids + if record.parent_id: + groups |= record.parent_id.group_ids + record.group_ids = groups diff --git a/document_page_group/pyproject.toml b/document_page_group/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/document_page_group/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/document_page_group/readme/CONTRIBUTORS.md b/document_page_group/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..2c972789bf6 --- /dev/null +++ b/document_page_group/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Enric Tobella \<\> +- \[APSL-Nagarro\](): + - Antoni Marroig \<\> diff --git a/document_page_group/readme/DESCRIPTION.md b/document_page_group/readme/DESCRIPTION.md new file mode 100644 index 00000000000..0555d10db56 --- /dev/null +++ b/document_page_group/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module allows to define groups on a category. diff --git a/document_page_group/security/document_page_security.xml b/document_page_group/security/document_page_security.xml new file mode 100644 index 00000000000..b8b99554415 --- /dev/null +++ b/document_page_group/security/document_page_security.xml @@ -0,0 +1,11 @@ + + + + document_page groups + + + ['|','&',('type', '=', 'content'),'|','|',('parent_id', '=', False), ('parent_id.group_ids','=',False),('parent_id.group_ids.users','=',user.id), '&', ('type', '=', 'category'), '|', ('group_ids', '=', False), ('group_ids.users', '=', user.id)] + + diff --git a/document_page_group/static/description/icon.png b/document_page_group/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/document_page_group/static/description/icon.png differ diff --git a/document_page_group/static/description/index.html b/document_page_group/static/description/index.html new file mode 100644 index 00000000000..192779b8215 --- /dev/null +++ b/document_page_group/static/description/index.html @@ -0,0 +1,424 @@ + + + + + +Document Page Group + + + +
+

Document Page Group

+ + +

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

+

This module allows to define groups on a category.

+

Table of contents

+ +
+

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

+
    +
  • Creu Blanca
  • +
+
+
+

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_group/tests/__init__.py b/document_page_group/tests/__init__.py new file mode 100644 index 00000000000..065b2bd05df --- /dev/null +++ b/document_page_group/tests/__init__.py @@ -0,0 +1 @@ +from . import test_document_page_group diff --git a/document_page_group/tests/test_document_page_group.py b/document_page_group/tests/test_document_page_group.py new file mode 100644 index 00000000000..b2aea7a2aef --- /dev/null +++ b/document_page_group/tests/test_document_page_group.py @@ -0,0 +1,48 @@ +# Copyright 2020 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestDocumentPageGroup(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + knowledge_group = cls.env.ref("document_knowledge.group_document_user").id + cls.user_id = cls.env["res.users"].create( + { + "name": "user", + "login": "login", + "email": "email", + "groups_id": [(4, knowledge_group)], + } + ) + cls.group = cls.env.ref("document_page.group_document_manager") + + cls.categ_1 = cls.env["document.page"].create( + {"name": "Categ 1", "type": "category"} + ) + cls.categ_2 = cls.env["document.page"].create( + {"name": "Categ 2", "type": "category", "parent_id": cls.categ_1.id} + ) + cls.page = cls.env["document.page"].create( + {"name": "Page 1", "type": "content", "parent_id": cls.categ_1.id} + ) + + def test_document_page_group(self): + pages = ( + self.env["document.page"] + .with_user(user=self.user_id.id) + .search([("type", "=", "content")]) + ) + self.assertIn(self.page.id, pages.ids) + + self.categ_1.write({"direct_group_ids": [(4, self.group.id)]}) + self.assertIn(self.group.id, self.categ_2.group_ids.ids) + + pages = ( + self.env["document.page"] + .with_user(user=self.user_id.id) + .search([("type", "=", "content")]) + ) + self.assertNotIn(self.page.id, pages.ids) diff --git a/document_page_group/views/document_page.xml b/document_page_group/views/document_page.xml new file mode 100644 index 00000000000..68ec0aa3029 --- /dev/null +++ b/document_page_group/views/document_page.xml @@ -0,0 +1,15 @@ + + + + + document.page.form (in document_page_group) + document.page + + + + + + + +