diff --git a/project_operating_unit/README.rst b/project_operating_unit/README.rst new file mode 100644 index 0000000000..4da1c2fa99 --- /dev/null +++ b/project_operating_unit/README.rst @@ -0,0 +1,104 @@ +============================ +Project with Operating Units +============================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:ffa9af0eebdc9ed3d2a8b8311a9c0971c702fd63d23beec4e614e3757d2ae444 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Foperating--unit-lightgray.png?logo=github + :target: https://github.com/OCA/operating-unit/tree/18.0/project_operating_unit + :alt: OCA/operating-unit +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/operating-unit-18-0/operating-unit-18-0-project_operating_unit + :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/operating-unit&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds operating unit information to projects and tasks. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +- Go to Project +- You only see the projects and tasks of your operating units +- Create a new project. It is assigned to your default operating unit. +- Create a task within a project. It inherits the operating unit of the + project. + +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 +------- + +* Open Source Integrators +* Serpent Consulting Services Pvt. Ltd. + +Contributors +------------ + +- Nikul Chaudhary +- Maxime Chambreuil +- Murtaza Mithaiwala +- Tran Thanh Trai +- ``Heliconia Solutions Pvt. Ltd. ``\ \_ + +Other credits +------------- + +- Open Source Integrators +- Serpent Consulting Services Pvt. Ltd. + +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-max3903| image:: https://github.com/max3903.png?size=40px + :target: https://github.com/max3903 + :alt: max3903 + +Current `maintainer `__: + +|maintainer-max3903| + +This module is part of the `OCA/operating-unit `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/project_operating_unit/__init__.py b/project_operating_unit/__init__.py new file mode 100644 index 0000000000..c32fd62b78 --- /dev/null +++ b/project_operating_unit/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import models diff --git a/project_operating_unit/__manifest__.py b/project_operating_unit/__manifest__.py new file mode 100644 index 0000000000..391763c9b0 --- /dev/null +++ b/project_operating_unit/__manifest__.py @@ -0,0 +1,26 @@ +# Copyright (C) 2019 Open Source Integrators +# Copyright (C) 2019 Serpent Consulting Services +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Project with Operating Units", + "summary": """ + This module adds operating unit information to projects and tasks.""", + "version": "18.0.1.0.0", + "author": "Open Source Integrators, " + "Serpent Consulting Services Pvt. Ltd., " + "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/operating-unit", + "category": "Project", + "depends": [ + "operating_unit", + "project", + ], + "license": "AGPL-3", + "data": [ + "security/project_security.xml", + "views/project_project.xml", + "views/project_task.xml", + ], + "development_status": "Beta", + "maintainers": ["max3903"], +} diff --git a/project_operating_unit/i18n/it.po b/project_operating_unit/i18n/it.po new file mode 100644 index 0000000000..424b428ace --- /dev/null +++ b/project_operating_unit/i18n/it.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_operating_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-01-19 07:35+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_operating_unit +#: model:ir.model.fields,field_description:project_operating_unit.field_project_project__operating_unit_id +#: model:ir.model.fields,field_description:project_operating_unit.field_project_task__operating_unit_id +#: model_terms:ir.ui.view,arch_db:project_operating_unit.project_group_by_ou +msgid "Operating Unit" +msgstr "Unità operativa" + +#. module: project_operating_unit +#: model:ir.model,name:project_operating_unit.model_project_project +msgid "Project" +msgstr "Progetto" + +#. module: project_operating_unit +#: model:ir.model,name:project_operating_unit.model_project_task +msgid "Task" +msgstr "Lavoro" diff --git a/project_operating_unit/i18n/project_operating_unit.pot b/project_operating_unit/i18n/project_operating_unit.pot new file mode 100644 index 0000000000..507ca64d98 --- /dev/null +++ b/project_operating_unit/i18n/project_operating_unit.pot @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_operating_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.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_operating_unit +#: model:ir.model.fields,field_description:project_operating_unit.field_project_project__operating_unit_id +#: model:ir.model.fields,field_description:project_operating_unit.field_project_task__operating_unit_id +#: model_terms:ir.ui.view,arch_db:project_operating_unit.project_group_by_ou +msgid "Operating Unit" +msgstr "" + +#. module: project_operating_unit +#: model:ir.model,name:project_operating_unit.model_project_project +msgid "Project" +msgstr "" + +#. module: project_operating_unit +#: model:ir.model,name:project_operating_unit.model_project_task +msgid "Task" +msgstr "" diff --git a/project_operating_unit/i18n/pt.po b/project_operating_unit/i18n/pt.po new file mode 100644 index 0000000000..7a9de7a96e --- /dev/null +++ b/project_operating_unit/i18n/pt.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_operating_unit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-02-29 15:13+0000\n" +"Last-Translator: Pedro Castro Silva \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 3.10\n" + +#. module: project_operating_unit +#: model:ir.model.fields,field_description:project_operating_unit.field_project_project__operating_unit_id +#: model:ir.model.fields,field_description:project_operating_unit.field_project_task__operating_unit_id +#: model_terms:ir.ui.view,arch_db:project_operating_unit.project_group_by_ou +msgid "Operating Unit" +msgstr "Unidade Operacional" + +#. module: project_operating_unit +#: model:ir.model,name:project_operating_unit.model_project_project +msgid "Project" +msgstr "Projeto" + +#. module: project_operating_unit +#: model:ir.model,name:project_operating_unit.model_project_task +msgid "Task" +msgstr "Tarefa" diff --git a/project_operating_unit/models/__init__.py b/project_operating_unit/models/__init__.py new file mode 100644 index 0000000000..6d7b86671a --- /dev/null +++ b/project_operating_unit/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import project_project +from . import project_task diff --git a/project_operating_unit/models/project_project.py b/project_operating_unit/models/project_project.py new file mode 100644 index 0000000000..0d91f9269d --- /dev/null +++ b/project_operating_unit/models/project_project.py @@ -0,0 +1,16 @@ +# Copyright (C) 2019 Open Source Integrators +# Copyright (C) 2019 Serpent Consulting Services +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ProjectProject(models.Model): + _inherit = "project.project" + + operating_unit_id = fields.Many2one( + comodel_name="operating.unit", + string="Operating Unit", + default=lambda self: self.env["res.users"]._get_default_operating_unit( + self._uid + ), + ) diff --git a/project_operating_unit/models/project_task.py b/project_operating_unit/models/project_task.py new file mode 100644 index 0000000000..60f59348ef --- /dev/null +++ b/project_operating_unit/models/project_task.py @@ -0,0 +1,14 @@ +# Copyright (C) 2019 Open Source Integrators +# Copyright (C) 2019 Serpent Consulting Services +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class ProjectTask(models.Model): + _inherit = "project.task" + + operating_unit_id = fields.Many2one( + comodel_name="operating.unit", + related="project_id.operating_unit_id", + string="Operating Unit", + ) diff --git a/project_operating_unit/pyproject.toml b/project_operating_unit/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/project_operating_unit/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/project_operating_unit/readme/CONTRIBUTORS.md b/project_operating_unit/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..9bb3704f2e --- /dev/null +++ b/project_operating_unit/readme/CONTRIBUTORS.md @@ -0,0 +1,5 @@ +- Nikul Chaudhary \<\> +- Maxime Chambreuil \<\> +- Murtaza Mithaiwala \<\> +- Tran Thanh Trai \<\> +- `Heliconia Solutions Pvt. Ltd. `_ diff --git a/project_operating_unit/readme/CREDITS.md b/project_operating_unit/readme/CREDITS.md new file mode 100644 index 0000000000..0b7870b0ae --- /dev/null +++ b/project_operating_unit/readme/CREDITS.md @@ -0,0 +1,2 @@ +- Open Source Integrators +- Serpent Consulting Services Pvt. Ltd. diff --git a/project_operating_unit/readme/DESCRIPTION.md b/project_operating_unit/readme/DESCRIPTION.md new file mode 100644 index 0000000000..b49aac6edb --- /dev/null +++ b/project_operating_unit/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module adds operating unit information to projects and tasks. diff --git a/project_operating_unit/readme/USAGE.md b/project_operating_unit/readme/USAGE.md new file mode 100644 index 0000000000..65031e59fe --- /dev/null +++ b/project_operating_unit/readme/USAGE.md @@ -0,0 +1,5 @@ +- Go to Project +- You only see the projects and tasks of your operating units +- Create a new project. It is assigned to your default operating unit. +- Create a task within a project. It inherits the operating unit of the + project. diff --git a/project_operating_unit/security/project_security.xml b/project_operating_unit/security/project_security.xml new file mode 100644 index 0000000000..539aa299e3 --- /dev/null +++ b/project_operating_unit/security/project_security.xml @@ -0,0 +1,31 @@ + + + + + ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',operating_unit_ids)] + + Project Operating Unit + + + + + + + + + ['|', ('operating_unit_id','=',False), ('operating_unit_id','in',operating_unit_ids)] + + Project Task Operating Unit + + + + + + + diff --git a/project_operating_unit/static/description/icon.png b/project_operating_unit/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/project_operating_unit/static/description/icon.png differ diff --git a/project_operating_unit/static/description/index.html b/project_operating_unit/static/description/index.html new file mode 100644 index 0000000000..e12ae75381 --- /dev/null +++ b/project_operating_unit/static/description/index.html @@ -0,0 +1,449 @@ + + + + + +Project with Operating Units + + + +
+

Project with Operating Units

+ + +

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

+

This module adds operating unit information to projects and tasks.

+

Table of contents

+ +
+

Usage

+
    +
  • Go to Project
  • +
  • You only see the projects and tasks of your operating units
  • +
  • Create a new project. It is assigned to your default operating unit.
  • +
  • Create a task within a project. It inherits the operating unit of the +project.
  • +
+
+
+

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

+
    +
  • Open Source Integrators
  • +
  • Serpent Consulting Services Pvt. Ltd.
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+
    +
  • Open Source Integrators
  • +
  • Serpent Consulting Services Pvt. Ltd.
  • +
+
+
+

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 maintainer:

+

max3903

+

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

+

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

+
+
+
+ + diff --git a/project_operating_unit/tests/__init__.py b/project_operating_unit/tests/__init__.py new file mode 100644 index 0000000000..8f99fb0e63 --- /dev/null +++ b/project_operating_unit/tests/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import test_project_operating_unit diff --git a/project_operating_unit/tests/test_project_operating_unit.py b/project_operating_unit/tests/test_project_operating_unit.py new file mode 100644 index 0000000000..d9e7e73c52 --- /dev/null +++ b/project_operating_unit/tests/test_project_operating_unit.py @@ -0,0 +1,112 @@ +# Copyright (C) 2019 Open Source Integrators +# Copyright (C) 2019 Serpent Consulting Services +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields +from odoo.tests import common + + +class TestProject(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.project_obj = cls.env["project.project"] + cls.task_obj = cls.env["project.task"] + cls.res_users_model = cls.env["res.users"] + + cls.partner_1 = cls.env["res.partner"].create( + {"name": "SERPENTCS ", "email": "serpentcs@gmail.com"} + ) + + # Groups + cls.grp_mngr = cls.env.ref("project.group_project_manager") + cls.grp_user = cls.env.ref("project.group_project_user") + # Company + cls.company = cls.env.ref("base.main_company") + # Main Operating Unit + cls.main_OU = cls.env.ref("operating_unit.main_operating_unit") + # B2C Operating Unit + cls.b2c_OU = cls.env.ref("operating_unit.b2c_operating_unit") + # Create User 1 with Main OU + cls.user1 = cls._create_user( + "user_1", [cls.grp_mngr, cls.grp_user], cls.company, [cls.main_OU] + ) + # Create User 2 with B2C OU + cls.user2 = cls._create_user( + "user_2", [cls.grp_mngr, cls.grp_user], cls.company, [cls.b2c_OU] + ) + + cls.project1 = cls._create_project(cls.user1, cls.main_OU) + cls.project2 = cls._create_project(cls.user2, cls.b2c_OU) + cls.task1 = cls._create_task(cls.user1, cls.project1) + cls.task2 = cls._create_task(cls.user2, cls.project2) + + @classmethod + def _create_user(cls, login, groups, company, operating_units): + """Create a user.""" + group_ids = [group.id for group in groups] + user = cls.res_users_model.create( + { + "name": login, + "login": login, + "password": "demo", + "email": "test@yourcompany.com", + "company_id": company.id, + "company_ids": [fields.Command.link(company.id)], + "operating_unit_ids": [ + fields.Command.link(ou.id) for ou in operating_units + ], + "groups_id": [fields.Command.set(group_ids)], + } + ) + return user + + @classmethod + def _create_project(cls, uid, operating_unit): + project = cls.project_obj.with_user(uid).create( + { + "name": "Test Project", + "operating_unit_id": operating_unit.id, + "privacy_visibility": "employees", + "partner_id": cls.partner_1.id, + } + ) + return project + + @classmethod + def _create_task(cls, uid, project): + task = cls.task_obj.create( + { + "name": "Test Task", + "user_ids": [fields.Command.link(uid.id)], + "project_id": project.id, + } + ) + return task + + def test_project(self): + # User 2 is only assigned to B2C Operating Unit, and cannot + # access Project for Main Operating Unit. + projects = self.project_obj.with_user(self.user2.id).search( + [("id", "=", self.project2.id), ("operating_unit_id", "=", self.main_OU.id)] + ) + self.assertEqual( + projects.ids, + [], + f"User 2 should not have access to {self.main_OU.name}", + ) + self.assertEqual(self.project1.operating_unit_id.id, self.main_OU.id) + + def test_project_task(self): + # User 2 is only assigned to B2C Operating Unit, and cannot + # access Task for Main Operating Unit. + tasks = self.task_obj.with_user(self.user2.id).search( + [("id", "=", self.task2.id), ("operating_unit_id", "=", self.main_OU.id)] + ) + self.assertEqual( + tasks.ids, + [], + f"User 2 should not have access to {self.main_OU.name}", + ) + self.assertEqual( + self.task1.operating_unit_id.id, self.project1.operating_unit_id.id + ) diff --git a/project_operating_unit/views/project_project.xml b/project_operating_unit/views/project_project.xml new file mode 100644 index 0000000000..2c1604ee89 --- /dev/null +++ b/project_operating_unit/views/project_project.xml @@ -0,0 +1,31 @@ + + + + project.project.form + project.project + + + + + + + + + project.group.by.ou + project.project + + + + + + + + diff --git a/project_operating_unit/views/project_task.xml b/project_operating_unit/views/project_task.xml new file mode 100644 index 0000000000..7a196bcadd --- /dev/null +++ b/project_operating_unit/views/project_task.xml @@ -0,0 +1,15 @@ + + + + project.task.form + project.task + + + + + + + +