diff --git a/project_group/README.rst b/project_group/README.rst new file mode 100644 index 0000000000..27c3229b6b --- /dev/null +++ b/project_group/README.rst @@ -0,0 +1,88 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +============= +Project Group +============= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d80c6e6c5d23df4b85f0d969f29a4168d71e3fe77c68980ea913055e0e5dfe0b + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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/19.0/project_group + :alt: OCA/project +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/project-19-0/project-19-0-project_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/project&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Allows us to define groups directly on projects. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Now, when we use Invited internal users options on visibility, a groups +field will appear. Then, all users with access to the project will be +able to see project and related tasks. + +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 +------- + +* Dixmit + +Contributors +------------ + +- Enric Tobella (``Dixmit ``\ \_\_) +- Xavier Bol + +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/project `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/project_group/__init__.py b/project_group/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/project_group/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/project_group/__manifest__.py b/project_group/__manifest__.py new file mode 100644 index 0000000000..c76336e771 --- /dev/null +++ b/project_group/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2025 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Project Group", + "summary": """Add groups for filtering on projects""", + "version": "19.0.1.0.0", + "license": "AGPL-3", + "author": "Dixmit, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/project", + "depends": ["project"], + "data": [ + "security/project_project.xml", + "views/project_project.xml", + ], + "demo": [], +} diff --git a/project_group/i18n/it.po b/project_group/i18n/it.po new file mode 100644 index 0000000000..f1e97b6e01 --- /dev/null +++ b/project_group/i18n/it.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-02-12 16:06+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 5.6.2\n" + +#. module: project_group +#: model:ir.model.fields,field_description:project_group.field_project_project__group_ids +msgid "Group" +msgstr "Gruppo" + +#. module: project_group +#: model:ir.model,name:project_group.model_project_project +msgid "Project" +msgstr "Progetto" diff --git a/project_group/i18n/project_group.pot b/project_group/i18n/project_group.pot new file mode 100644 index 0000000000..abedced062 --- /dev/null +++ b/project_group/i18n/project_group.pot @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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_group +#: model:ir.model.fields,field_description:project_group.field_project_project__group_ids +msgid "Group" +msgstr "" + +#. module: project_group +#: model:ir.model,name:project_group.model_project_project +msgid "Project" +msgstr "" diff --git a/project_group/models/__init__.py b/project_group/models/__init__.py new file mode 100644 index 0000000000..56545d0d4f --- /dev/null +++ b/project_group/models/__init__.py @@ -0,0 +1 @@ +from . import project_project diff --git a/project_group/models/project_project.py b/project_group/models/project_project.py new file mode 100644 index 0000000000..1f1e6b2a81 --- /dev/null +++ b/project_group/models/project_project.py @@ -0,0 +1,10 @@ +# Copyright 2025 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ProjectProject(models.Model): + _inherit = "project.project" + + group_ids = fields.Many2many("res.groups", string="Groups") diff --git a/project_group/pyproject.toml b/project_group/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/project_group/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/project_group/readme/CONTRIBUTORS.md b/project_group/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..9a3655f41a --- /dev/null +++ b/project_group/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Enric Tobella (`Dixmit `__) +- Xavier Bol \<\> diff --git a/project_group/readme/DESCRIPTION.md b/project_group/readme/DESCRIPTION.md new file mode 100644 index 0000000000..e186df8589 --- /dev/null +++ b/project_group/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Allows us to define groups directly on projects. diff --git a/project_group/readme/USAGE.md b/project_group/readme/USAGE.md new file mode 100644 index 0000000000..edb8498693 --- /dev/null +++ b/project_group/readme/USAGE.md @@ -0,0 +1 @@ +Now, when we use Invited internal users options on visibility, a groups field will appear. Then, all users with access to the project will be able to see project and related tasks. diff --git a/project_group/security/project_project.xml b/project_group/security/project_project.xml new file mode 100644 index 0000000000..7bbfb19a13 --- /dev/null +++ b/project_group/security/project_project.xml @@ -0,0 +1,25 @@ + + + + + Project: employees: Groups + + [ + ('privacy_visibility', '=', 'followers'), + ('group_ids', 'in', user.all_group_ids.ids) + ] + + + + + Task: employees: Groups + + [ + ('project_id', '!=', False), + ('project_id.privacy_visibility', '=', 'followers'), + ('project_id.group_ids', 'in', user.all_group_ids.ids) + ] + + + diff --git a/project_group/static/description/icon.png b/project_group/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/project_group/static/description/icon.png differ diff --git a/project_group/static/description/index.html b/project_group/static/description/index.html new file mode 100644 index 0000000000..e6dba9a50b --- /dev/null +++ b/project_group/static/description/index.html @@ -0,0 +1,437 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Project Group

+ +

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

+

Allows us to define groups directly on projects.

+

Table of contents

+ +
+

Usage

+

Now, when we use Invited internal users options on visibility, a groups +field will appear. Then, all users with access to the project will be +able to see project and related tasks.

+
+
+

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

+
    +
  • Dixmit
  • +
+
+
+

Contributors

+
    +
  • Enric Tobella (Dixmit <https://www.dixmit.com/>__)
  • +
  • Xavier Bol <xavierbol@ik.me>
  • +
+
+
+

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/project project on GitHub.

+

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

+
+
+
+
+ + diff --git a/project_group/tests/__init__.py b/project_group/tests/__init__.py new file mode 100644 index 0000000000..cacdf75892 --- /dev/null +++ b/project_group/tests/__init__.py @@ -0,0 +1 @@ +from . import test_project_visibility diff --git a/project_group/tests/test_project_visibility.py b/project_group/tests/test_project_visibility.py new file mode 100644 index 0000000000..6a8dea12fe --- /dev/null +++ b/project_group/tests/test_project_visibility.py @@ -0,0 +1,108 @@ +from odoo import Command + +from odoo.addons.base.tests.common import BaseCommon +from odoo.addons.mail.tests.common import mail_new_test_user + + +class TestProjectVisibility(BaseCommon): + @classmethod + def setUpClass(cls): + """Set up the class with initial data for tests.""" + super().setUpClass() + cls.ProjectObj = cls.env["project.project"] + cls.GroupObj = cls.env["res.groups"] + cls.project_group_user = mail_new_test_user( + cls.env, + login="projectgroupuser", + name="Project Group User", + email="projectgroupuser@example.com", + company_id=cls.env.company.id, + groups="base.group_user", + ) + cls.group1 = cls.GroupObj.create({"name": "Test Group 1"}) + cls.group2 = cls.GroupObj.create({"name": "Test Group 2"}) + cls.project = cls.ProjectObj.create( + {"name": "Test Project", "privacy_visibility": "portal"} + ) + cls.restricted_project = cls.ProjectObj.create( + { + "name": "Restricted Project", + "privacy_visibility": "followers", + "group_ids": [Command.set([cls.group1.id])], + } + ) + + def test_01_group_ids_visibility(self): + """Test the visibility of group_ids based on project privacy settings.""" + self.assertFalse( + self.project.group_ids, + "group_ids should not be set when visibility is 'portal'", + ) + self.assertEqual( + self.project.privacy_visibility, + "portal", + "privacy_visibility should be 'portal' initially", + ) + + self.project.write( + { + "privacy_visibility": "followers", + "group_ids": [Command.set([self.group1.id, self.group2.id])], + } + ) + self.assertEqual( + self.project.privacy_visibility, + "followers", + "privacy_visibility should be 'followers' after update", + ) + self.assertTrue( + self.project.group_ids, + "group_ids should be set when visibility is 'followers'", + ) + self.assertEqual( + len(self.project.group_ids), 2, "There should be two groups assigned" + ) + + self.project.write( + { + "privacy_visibility": "employees", + } + ) + self.assertEqual( + self.project.privacy_visibility, + "employees", + "privacy_visibility should be 'employees' after update", + ) + + def test_02_access_rights(self): + """Test the access rights of users based on group membership.""" + self.assertEqual( + self.restricted_project.privacy_visibility, + "followers", + "privacy_visibility should be 'followers' initially", + ) + + self.project_group_user.write({"group_ids": [Command.set([self.group2.id])]}) + self.assertNotIn( + self.project_group_user, + self.restricted_project.sudo().group_ids.all_user_ids, + "User should not have access", + ) + + self.project_group_user.write({"group_ids": [Command.set([self.group1.id])]}) + self.assertIn( + self.project_group_user, + self.restricted_project.sudo().group_ids.all_user_ids, + "User should have access", + ) + + self.restricted_project.write( + { + "privacy_visibility": "employees", + } + ) + self.assertEqual( + self.restricted_project.privacy_visibility, + "employees", + "privacy_visibility should be 'employees' after update", + ) diff --git a/project_group/views/project_project.xml b/project_group/views/project_project.xml new file mode 100644 index 0000000000..e129a5ac74 --- /dev/null +++ b/project_group/views/project_project.xml @@ -0,0 +1,18 @@ + + + + + project.project + + + + + + + +