diff --git a/project_tag_hierarchy/README.rst b/project_tag_hierarchy/README.rst new file mode 100644 index 0000000000..cd5655159f --- /dev/null +++ b/project_tag_hierarchy/README.rst @@ -0,0 +1,86 @@ +===================== +Project Tag Hierarchy +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:8bc6b8773d35a27848dfa44a2d7533a65edb084565cce8858359ee2066497621 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/16.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-16-0/project-16-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=16.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..5206d5b30c --- /dev/null +++ b/project_tag_hierarchy/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Project Tag Hierarchy", + "version": "16.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, + "auto_install": 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/project_tag_hierarchy.pot b/project_tag_hierarchy/i18n/project_tag_hierarchy.pot new file mode 100644 index 0000000000..7081ddc377 --- /dev/null +++ b/project_tag_hierarchy/i18n/project_tag_hierarchy.pot @@ -0,0 +1,43 @@ +# 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 11:32+0000\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..471a26e022 --- /dev/null +++ b/project_tag_hierarchy/models/project_tags.py @@ -0,0 +1,33 @@ +# 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 +from odoo.exceptions import ValidationError + + +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) + + def name_get(self): + res = [] + for tag in self: + names = [] + current = tag + while current: + names.append(current.name) + current = current.parent_id + res.append((tag.id, " / ".join(reversed(names)))) + return res + + @api.constrains("parent_id") + def _check_parent_id(self): + if not self._check_recursion(): + raise ValidationError(_("You can not create recursive tags.")) diff --git a/project_tag_hierarchy/readme/CONTRIBUTORS.rst b/project_tag_hierarchy/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..2327c90dff --- /dev/null +++ b/project_tag_hierarchy/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Tecnativa `_: + * Víctor Martínez + * Pedro M. Baeza diff --git a/project_tag_hierarchy/readme/DESCRIPTION.rst b/project_tag_hierarchy/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..5d769a0eaa --- /dev/null +++ b/project_tag_hierarchy/readme/DESCRIPTION.rst @@ -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..108d05c5de --- /dev/null +++ b/project_tag_hierarchy/static/description/index.html @@ -0,0 +1,424 @@ + + + + + +Project Tag Hierarchy + + + +
+

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..a9645fb5e7 --- /dev/null +++ b/project_tag_hierarchy/tests/test_project_tag_hierarchy.py @@ -0,0 +1,25 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.addons.base.tests.common import BaseCommon + + +class TestProjectTagHierarchy(BaseCommon): + @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_name_get(self): + tag_1_name = self.tag_1.name_get() + self.assertEqual(tag_1_name[0][1], "Tag 1") + tag_2_name = self.tag_2.name_get() + self.assertEqual(tag_2_name[0][1], "Tag 1 / Tag 2") + tag_3_name = self.tag_3.name_get() + self.assertEqual(tag_3_name[0][1], "Tag 1 / Tag 2 / 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 + + + + + + + + diff --git a/setup/project_tag_hierarchy/odoo/addons/project_tag_hierarchy b/setup/project_tag_hierarchy/odoo/addons/project_tag_hierarchy new file mode 120000 index 0000000000..007aa8a742 --- /dev/null +++ b/setup/project_tag_hierarchy/odoo/addons/project_tag_hierarchy @@ -0,0 +1 @@ +../../../../project_tag_hierarchy \ No newline at end of file diff --git a/setup/project_tag_hierarchy/setup.py b/setup/project_tag_hierarchy/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/project_tag_hierarchy/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)