diff --git a/project_administrator_restricted_visibility/README.rst b/project_administrator_restricted_visibility/README.rst new file mode 100644 index 0000000000..70ff50906e --- /dev/null +++ b/project_administrator_restricted_visibility/README.rst @@ -0,0 +1,113 @@ +=========================================== +Project Administrator Restricted Visibility +=========================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:acd93071523d12e6bb59197e0b1fdebf319b1ae3f4e6e1ac0b019a9644283e5f + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fproject-lightgray.png?logo=github + :target: https://github.com/OCA/project/tree/17.0/project_administrator_restricted_visibility + :alt: OCA/project +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/project-17-0/project-17-0-project_administrator_restricted_visibility + :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/project&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of 'Project' module to add a new +'Project Administrator' access group with restricted visibility to the +projects. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module, you need to: + +1. Go to *Settings > Users & Companies > Users* +2. Create a user or edit an existing one. +3. A new access group called 'Restricted Project Administrator' under + the 'Projects' category can be selected. + +Usage +===== + +The new group has the same access rights as the administrator (and see +the same menus), but the project visibility is restricted as a project +user. + +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 +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__: + + - Ernesto Tejeda + - Pilar Vargas + +- `Moduon `__: + + - Eduardo López + +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. + +.. |maintainer-rafaelbn| image:: https://github.com/rafaelbn.png?size=40px + :target: https://github.com/rafaelbn + :alt: rafaelbn +.. |maintainer-edlopen| image:: https://github.com/edlopen.png?size=40px + :target: https://github.com/edlopen + :alt: edlopen + +Current `maintainers `__: + +|maintainer-rafaelbn| |maintainer-edlopen| + +This module is part of the `OCA/project `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/project_administrator_restricted_visibility/__init__.py b/project_administrator_restricted_visibility/__init__.py new file mode 100644 index 0000000000..1ccbfaa566 --- /dev/null +++ b/project_administrator_restricted_visibility/__init__.py @@ -0,0 +1 @@ +from .hooks import uninstall_hook diff --git a/project_administrator_restricted_visibility/__manifest__.py b/project_administrator_restricted_visibility/__manifest__.py new file mode 100644 index 0000000000..78a07617fc --- /dev/null +++ b/project_administrator_restricted_visibility/__manifest__.py @@ -0,0 +1,14 @@ +{ + "name": "Project Administrator Restricted Visibility", + "version": "17.0.1.0.0", + "summary": "Adds a 'Project Administrator' access group " + "with restricted visibility to 'Projects'", + "author": "Tecnativa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/project", + "license": "AGPL-3", + "category": "Project", + "depends": ["project"], + "data": ["security/project_security.xml"], + "uninstall_hook": "uninstall_hook", + "maintainers": ["rafaelbn", "edlopen"], +} diff --git a/project_administrator_restricted_visibility/hooks.py b/project_administrator_restricted_visibility/hooks.py new file mode 100644 index 0000000000..f4affb0c44 --- /dev/null +++ b/project_administrator_restricted_visibility/hooks.py @@ -0,0 +1,27 @@ +# Copyright 2023 Tecnativa - Ernesto Tejeda +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import SUPERUSER_ID, api + + +def uninstall_hook(cr, registry): + """Restore project.project_project_manager_rule""" + env = api.Environment(cr, SUPERUSER_ID, {}) + # Removing the 'group_full_project_manager' group before renaming the original + # 'Project: Administrator' group (project.group_project_manager) to 'Administrator' + # in order to avoid getting a SQL constraint error: + # 'duplicate key value violates unique constraint "res_groups_name_uniq'" + group_full_project_manager = env.ref( + "project_administrator_restricted_visibility.group_full_project_manager" + ) + env.ref("project.project_project_manager_rule").write( + {"groups": [(3, group_full_project_manager.id)]} + ) + group_full_project_manager.unlink() + # Rename the original 'Project: Administrator' access group back to 'Administrator' + # and reassign the access rule for projects that it previously had. + env.ref("project.group_project_manager").write( + { + "name": "Administrator", + "rule_groups": [(4, env.ref("project.project_project_manager_rule").id)], + } + ) diff --git a/project_administrator_restricted_visibility/i18n/it.po b/project_administrator_restricted_visibility/i18n/it.po new file mode 100644 index 0000000000..fabd1a9cd7 --- /dev/null +++ b/project_administrator_restricted_visibility/i18n/it.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_administrator_restricted_visibility +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-06-19 08:08+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: project_administrator_restricted_visibility +#: model:res.groups,name:project_administrator_restricted_visibility.group_full_project_manager +msgid "Full Administrator" +msgstr "Gestione completa" + +#~ msgid "Administrator" +#~ msgstr "Amministratore" diff --git a/project_administrator_restricted_visibility/i18n/project_administrator_restricted_visibility.pot b/project_administrator_restricted_visibility/i18n/project_administrator_restricted_visibility.pot new file mode 100644 index 0000000000..d5ea1c6910 --- /dev/null +++ b/project_administrator_restricted_visibility/i18n/project_administrator_restricted_visibility.pot @@ -0,0 +1,19 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_administrator_restricted_visibility +# +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: project_administrator_restricted_visibility +#: model:res.groups,name:project_administrator_restricted_visibility.group_full_project_manager +msgid "Full Administrator" +msgstr "" diff --git a/project_administrator_restricted_visibility/pyproject.toml b/project_administrator_restricted_visibility/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/project_administrator_restricted_visibility/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/project_administrator_restricted_visibility/readme/CONFIGURE.md b/project_administrator_restricted_visibility/readme/CONFIGURE.md new file mode 100644 index 0000000000..527d12def3 --- /dev/null +++ b/project_administrator_restricted_visibility/readme/CONFIGURE.md @@ -0,0 +1,6 @@ +To configure this module, you need to: + +1. Go to *Settings \> Users & Companies \> Users* +2. Create a user or edit an existing one. +3. A new access group called 'Restricted Project Administrator' under + the 'Projects' category can be selected. diff --git a/project_administrator_restricted_visibility/readme/CONTRIBUTORS.md b/project_administrator_restricted_visibility/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..46ffee0ad1 --- /dev/null +++ b/project_administrator_restricted_visibility/readme/CONTRIBUTORS.md @@ -0,0 +1,5 @@ +- [Tecnativa](https://www.tecnativa.com): + - Ernesto Tejeda + - Pilar Vargas +- [Moduon](https://www.moduon.team): + - Eduardo López diff --git a/project_administrator_restricted_visibility/readme/DESCRIPTION.md b/project_administrator_restricted_visibility/readme/DESCRIPTION.md new file mode 100644 index 0000000000..7ce4c7373b --- /dev/null +++ b/project_administrator_restricted_visibility/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +This module extends the functionality of 'Project' module to add a new +'Project Administrator' access group with restricted visibility to the +projects. diff --git a/project_administrator_restricted_visibility/readme/USAGE.md b/project_administrator_restricted_visibility/readme/USAGE.md new file mode 100644 index 0000000000..ff1ab4fb1c --- /dev/null +++ b/project_administrator_restricted_visibility/readme/USAGE.md @@ -0,0 +1,3 @@ +The new group has the same access rights as the administrator (and see +the same menus), but the project visibility is restricted as a project +user. diff --git a/project_administrator_restricted_visibility/security/project_security.xml b/project_administrator_restricted_visibility/security/project_security.xml new file mode 100644 index 0000000000..a8eda72081 --- /dev/null +++ b/project_administrator_restricted_visibility/security/project_security.xml @@ -0,0 +1,23 @@ + + + + + Restricted Administrator + + + + + Full Administrator + + + + + diff --git a/project_administrator_restricted_visibility/static/description/icon.png b/project_administrator_restricted_visibility/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/project_administrator_restricted_visibility/static/description/icon.png differ diff --git a/project_administrator_restricted_visibility/static/description/index.html b/project_administrator_restricted_visibility/static/description/index.html new file mode 100644 index 0000000000..9b7fe39912 --- /dev/null +++ b/project_administrator_restricted_visibility/static/description/index.html @@ -0,0 +1,453 @@ + + + + + +Project Administrator Restricted Visibility + + + +
+

Project Administrator Restricted Visibility

+ + +

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

+

This module extends the functionality of ‘Project’ module to add a new +‘Project Administrator’ access group with restricted visibility to the +projects.

+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  1. Go to Settings > Users & Companies > Users
  2. +
  3. Create a user or edit an existing one.
  4. +
  5. A new access group called ‘Restricted Project Administrator’ under +the ‘Projects’ category can be selected.
  6. +
+
+
+

Usage

+

The new group has the same access rights as the administrator (and see +the same menus), but the project visibility is restricted as a project +user.

+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Ernesto Tejeda
    • +
    • Pilar Vargas
    • +
    +
  • +
  • Moduon:
      +
    • Eduardo López
    • +
    +
  • +
+
+
+

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.

+

Current maintainers:

+

rafaelbn edlopen

+

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

+

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

+
+
+
+ + diff --git a/project_administrator_restricted_visibility/tests/__init__.py b/project_administrator_restricted_visibility/tests/__init__.py new file mode 100644 index 0000000000..0ea0fe18c7 --- /dev/null +++ b/project_administrator_restricted_visibility/tests/__init__.py @@ -0,0 +1,2 @@ +from . import test_project_administrator_restricted_visibility +from . import test_uninstall_hook diff --git a/project_administrator_restricted_visibility/tests/test_project_administrator_restricted_visibility.py b/project_administrator_restricted_visibility/tests/test_project_administrator_restricted_visibility.py new file mode 100644 index 0000000000..4150e86c7b --- /dev/null +++ b/project_administrator_restricted_visibility/tests/test_project_administrator_restricted_visibility.py @@ -0,0 +1,49 @@ +# Copyright 2023 Tecnativa - Ernesto Tejeda +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo.tests.common import TransactionCase, new_test_user, users + + +class TestProjectAdministratorRestrictedVisibility(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.project_obj = cls.env["project.project"] + cls.user_admin = cls.env.ref("base.user_admin") + cls.user_user_padmin = new_test_user( + cls.env, + login="project-user", + groups="project.group_project_user", + ) + cls.user_restrcited_padmin = new_test_user( + cls.env, + login="restricted-project-admin", + groups="project.group_project_manager", + ) + cls.user_full_padmin = new_test_user( + cls.env, + login="project-admin", + groups="project_administrator_restricted_visibility.group_full_project_manager", + ) + cls.restricted_project = cls.env["project.project"].create( + { + "name": "Restricted project", + "privacy_visibility": "followers", + "user_id": cls.user_admin.id, + "message_partner_ids": [(6, 0, cls.user_admin.ids)], + } + ) + + @users("restricted-project-admin", "project-admin") + def test_create_new_project(self): + """'Restricted project administrator' can create + projects like a 'Project administrator'. + """ + self.project_obj.create({"name": "Another project"}) + + @users("restricted-project-admin", "project-user") + def test_cant_see_restricted_projects(self): + """'Restricted project administrator' has the same project restriction + as the 'Project user'. + """ + all_project = self.env["project.project"].search([]) + self.assertNotIn(self.restricted_project, all_project) diff --git a/project_administrator_restricted_visibility/tests/test_uninstall_hook.py b/project_administrator_restricted_visibility/tests/test_uninstall_hook.py new file mode 100644 index 0000000000..8526c705dc --- /dev/null +++ b/project_administrator_restricted_visibility/tests/test_uninstall_hook.py @@ -0,0 +1,28 @@ +# Copyright 2024 Moduon Team S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo.tests.common import TransactionCase + +from ..hooks import uninstall_hook + + +class TestUninstallHook(TransactionCase): + def test_01_uninstall_hook(self): + restricted_group = self.env.ref("project.group_project_manager") + full_group = self.env.ref( + "project_administrator_restricted_visibility.group_full_project_manager" + ) + manager_rule = self.env.ref("project.project_project_manager_rule") + # Checks Restricted Administrator Group has not project manager rule + self.assertFalse( + any(set(restricted_group.rule_groups.ids) & set(manager_rule.ids)) + ) + # Checks Full Administrator Group has project manager rule + self.assertTrue(any(set(full_group.rule_groups.ids) & set(manager_rule.ids))) + + uninstall_hook(self.env.cr, False) + + # Checks if the rules have been reset + self.assertTrue( + any(set(restricted_group.rule_groups.ids) & set(manager_rule.ids)) + ) + self.assertFalse(any(set(full_group.rule_groups.ids) & set(manager_rule.ids)))