diff --git a/project_tag_hierarchy/README.rst b/project_tag_hierarchy/README.rst new file mode 100644 index 0000000000..5e8998cf32 --- /dev/null +++ b/project_tag_hierarchy/README.rst @@ -0,0 +1,91 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +===================== +Project Tag Hierarchy +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:57499644143ceb71397ff3ffdd68d1c0cd763321fa888af4cea2e85e9afacc83 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/17.0/project_tag_hierarchy + :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_tag_hierarchy + :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| + +Hierarchy is added to the project labels. + +**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 +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__: + + - Víctor Martínez + - Pedro M. Baeza + +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-victoralmau| image:: https://github.com/victoralmau.png?size=40px + :target: https://github.com/victoralmau + :alt: victoralmau + +Current `maintainer `__: + +|maintainer-victoralmau| + +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_tag_hierarchy/__init__.py b/project_tag_hierarchy/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/project_tag_hierarchy/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/project_tag_hierarchy/__manifest__.py b/project_tag_hierarchy/__manifest__.py new file mode 100644 index 0000000000..b7f5f5fc41 --- /dev/null +++ b/project_tag_hierarchy/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Project Tag Hierarchy", + "version": "17.0.1.0.0", + "category": "Project Management", + "website": "https://github.com/OCA/project", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["project"], + "installable": True, + "data": [ + "views/project_tags_views.xml", + ], + "maintainers": ["victoralmau"], +} diff --git a/project_tag_hierarchy/i18n/es.po b/project_tag_hierarchy/i18n/es.po new file mode 100644 index 0000000000..1088a6f5e7 --- /dev/null +++ b/project_tag_hierarchy/i18n/es.po @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_tag_hierarchy +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-11 11:32+0000\n" +"PO-Revision-Date: 2024-10-11 13:33+0200\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 3.0.1\n" + +#. module: project_tag_hierarchy +#: model:ir.model.fields,field_description:project_tag_hierarchy.field_project_tags__child_ids +msgid "Child Tags" +msgstr "Etiquetas hijas" + +#. module: project_tag_hierarchy +#: model:ir.model.fields,field_description:project_tag_hierarchy.field_project_tags__parent_path +msgid "Parent Path" +msgstr "Ruta padre" + +#. module: project_tag_hierarchy +#: model:ir.model.fields,field_description:project_tag_hierarchy.field_project_tags__parent_id +msgid "Parent Tag" +msgstr "Etiqueta padre" + +#. module: project_tag_hierarchy +#: model:ir.model,name:project_tag_hierarchy.model_project_tags +msgid "Project Tags" +msgstr "Etiquetas del proyecto" + +#. module: project_tag_hierarchy +#. odoo-python +#: code:addons/project_tag_hierarchy/models/project_tags.py:0 +#, python-format +msgid "You can not create recursive tags." +msgstr "No puede crear etiquetas recursivas." diff --git a/project_tag_hierarchy/i18n/it.po b/project_tag_hierarchy/i18n/it.po new file mode 100644 index 0000000000..70e5fbabe4 --- /dev/null +++ b/project_tag_hierarchy/i18n/it.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_tag_hierarchy +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-10-21 10: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_tag_hierarchy +#: model:ir.model.fields,field_description:project_tag_hierarchy.field_project_tags__child_ids +msgid "Child Tags" +msgstr "Etichette figlie" + +#. module: project_tag_hierarchy +#: model:ir.model.fields,field_description:project_tag_hierarchy.field_project_tags__parent_path +msgid "Parent Path" +msgstr "Percorso padre" + +#. module: project_tag_hierarchy +#: model:ir.model.fields,field_description:project_tag_hierarchy.field_project_tags__parent_id +msgid "Parent Tag" +msgstr "Etichetta padre" + +#. module: project_tag_hierarchy +#: model:ir.model,name:project_tag_hierarchy.model_project_tags +msgid "Project Tags" +msgstr "Etichette progetto" + +#. module: project_tag_hierarchy +#. odoo-python +#: code:addons/project_tag_hierarchy/models/project_tags.py:0 +#, python-format +msgid "You can not create recursive tags." +msgstr "Non si possono creare etichette ricorsive." diff --git a/project_tag_hierarchy/i18n/project_tag_hierarchy.pot b/project_tag_hierarchy/i18n/project_tag_hierarchy.pot new file mode 100644 index 0000000000..fafdf10e7e --- /dev/null +++ b/project_tag_hierarchy/i18n/project_tag_hierarchy.pot @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_tag_hierarchy +# +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_tag_hierarchy +#: model:ir.model.fields,field_description:project_tag_hierarchy.field_project_tags__child_ids +msgid "Child Tags" +msgstr "" + +#. module: project_tag_hierarchy +#: model:ir.model.fields,field_description:project_tag_hierarchy.field_project_tags__parent_path +msgid "Parent Path" +msgstr "" + +#. module: project_tag_hierarchy +#: model:ir.model.fields,field_description:project_tag_hierarchy.field_project_tags__parent_id +msgid "Parent Tag" +msgstr "" + +#. module: project_tag_hierarchy +#: model:ir.model,name:project_tag_hierarchy.model_project_tags +msgid "Project Tags" +msgstr "" + +#. module: project_tag_hierarchy +#. odoo-python +#: code:addons/project_tag_hierarchy/models/project_tags.py:0 +#, python-format +msgid "You can not create recursive tags." +msgstr "" diff --git a/project_tag_hierarchy/models/__init__.py b/project_tag_hierarchy/models/__init__.py new file mode 100644 index 0000000000..c94a97032d --- /dev/null +++ b/project_tag_hierarchy/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import project_tags diff --git a/project_tag_hierarchy/models/project_tags.py b/project_tag_hierarchy/models/project_tags.py new file mode 100644 index 0000000000..7d9d1f6620 --- /dev/null +++ b/project_tag_hierarchy/models/project_tags.py @@ -0,0 +1,26 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) +from odoo import api, fields, models + + +class ProjectTags(models.Model): + _inherit = "project.tags" + _parent_store = True + + parent_id = fields.Many2one( + comodel_name="project.tags", string="Parent Tag", index=True, ondelete="cascade" + ) + child_ids = fields.One2many( + comodel_name="project.tags", inverse_name="parent_id", string="Child Tags" + ) + parent_path = fields.Char(index=True, unaccent=False) + + @api.depends("name", "parent_id") + def _compute_display_name(self): + for tag in self: + names = [] + current = tag + while current: + names.append(current.name) + current = current.parent_id + tag.display_name = " / ".join(reversed(names)) diff --git a/project_tag_hierarchy/pyproject.toml b/project_tag_hierarchy/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/project_tag_hierarchy/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/project_tag_hierarchy/readme/CONTRIBUTORS.md b/project_tag_hierarchy/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..5fee390427 --- /dev/null +++ b/project_tag_hierarchy/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [Tecnativa](https://www.tecnativa.com): + - Víctor Martínez + - Pedro M. Baeza diff --git a/project_tag_hierarchy/readme/DESCRIPTION.md b/project_tag_hierarchy/readme/DESCRIPTION.md new file mode 100644 index 0000000000..5d769a0eaa --- /dev/null +++ b/project_tag_hierarchy/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Hierarchy is added to the project labels. diff --git a/project_tag_hierarchy/static/description/icon.png b/project_tag_hierarchy/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/project_tag_hierarchy/static/description/icon.png differ diff --git a/project_tag_hierarchy/static/description/index.html b/project_tag_hierarchy/static/description/index.html new file mode 100644 index 0000000000..af57929e33 --- /dev/null +++ b/project_tag_hierarchy/static/description/index.html @@ -0,0 +1,435 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Project Tag Hierarchy

+ +

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

+

Hierarchy is added to the project labels.

+

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

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Víctor Martínez
    • +
    • Pedro M. Baeza
    • +
    +
  • +
+
+
+

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:

+

victoralmau

+

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_tag_hierarchy/tests/__init__.py b/project_tag_hierarchy/tests/__init__.py new file mode 100644 index 0000000000..a58564d47b --- /dev/null +++ b/project_tag_hierarchy/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_project_tag_hierarchy diff --git a/project_tag_hierarchy/tests/test_project_tag_hierarchy.py b/project_tag_hierarchy/tests/test_project_tag_hierarchy.py new file mode 100644 index 0000000000..d1f82b3fb8 --- /dev/null +++ b/project_tag_hierarchy/tests/test_project_tag_hierarchy.py @@ -0,0 +1,30 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.exceptions import UserError +from odoo.tests import tagged + +from odoo.addons.base.tests.common import TransactionCase + + +@tagged("post_install", "-at_install") +class TestProjectTagHierarchy(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.tag_1 = cls.env["project.tags"].create({"name": "Tag 1"}) + cls.tag_2 = cls.env["project.tags"].create( + {"name": "Tag 2", "parent_id": cls.tag_1.id} + ) + cls.tag_3 = cls.env["project.tags"].create( + {"name": "Tag 3", "parent_id": cls.tag_2.id} + ) + + def test_project_tag_display_name(self): + self.assertEqual(self.tag_1.display_name, "Tag 1") + self.assertEqual(self.tag_2.display_name, "Tag 1 / Tag 2") + self.assertEqual(self.tag_3.display_name, "Tag 1 / Tag 2 / Tag 3") + + def test_project_tag_recursion(self): + with self.assertRaises(UserError): + self.tag_1.parent_id = self.tag_3 diff --git a/project_tag_hierarchy/views/project_tags_views.xml b/project_tag_hierarchy/views/project_tags_views.xml new file mode 100644 index 0000000000..75f73179a6 --- /dev/null +++ b/project_tag_hierarchy/views/project_tags_views.xml @@ -0,0 +1,23 @@ + + + + project.tags.tree + project.tags + + + + + + + + + project.tags.form + project.tags + + + + + + + +