From 442d0399f48e7b17d80c1d8536057f24f4b284ed Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Mon, 2 Oct 2023 09:22:39 +0200 Subject: [PATCH] [ADD] maintennace_category_hierarchy --- .../README.rst | 78 ++++ .../__init__.py | 1 + .../__manifest__.py | 14 + .../i18n/es.po | 59 +++ ...intenance_equipment_category_hierarchy.pot | 58 +++ .../models/__init__.py | 1 + .../models/maintenance_equipment_category.py | 48 ++ .../readme/CONTRIBUTORS.rst | 4 + .../readme/DESCRIPTION.rst | 0 .../static/description/index.html | 423 ++++++++++++++++++ .../tests/__init__.py | 1 + .../tests/test_maintenance_category.py | 21 + .../views/maintenance_equipment_category.xml | 42 ++ .../maintenance_equipment_category_hierarchy | 1 + .../setup.py | 6 + 15 files changed, 757 insertions(+) create mode 100644 maintenance_equipment_category_hierarchy/README.rst create mode 100644 maintenance_equipment_category_hierarchy/__init__.py create mode 100644 maintenance_equipment_category_hierarchy/__manifest__.py create mode 100644 maintenance_equipment_category_hierarchy/i18n/es.po create mode 100644 maintenance_equipment_category_hierarchy/i18n/maintenance_equipment_category_hierarchy.pot create mode 100644 maintenance_equipment_category_hierarchy/models/__init__.py create mode 100644 maintenance_equipment_category_hierarchy/models/maintenance_equipment_category.py create mode 100644 maintenance_equipment_category_hierarchy/readme/CONTRIBUTORS.rst create mode 100644 maintenance_equipment_category_hierarchy/readme/DESCRIPTION.rst create mode 100644 maintenance_equipment_category_hierarchy/static/description/index.html create mode 100644 maintenance_equipment_category_hierarchy/tests/__init__.py create mode 100644 maintenance_equipment_category_hierarchy/tests/test_maintenance_category.py create mode 100644 maintenance_equipment_category_hierarchy/views/maintenance_equipment_category.xml create mode 120000 setup/maintenance_equipment_category_hierarchy/odoo/addons/maintenance_equipment_category_hierarchy create mode 100644 setup/maintenance_equipment_category_hierarchy/setup.py diff --git a/maintenance_equipment_category_hierarchy/README.rst b/maintenance_equipment_category_hierarchy/README.rst new file mode 100644 index 000000000..66e84716c --- /dev/null +++ b/maintenance_equipment_category_hierarchy/README.rst @@ -0,0 +1,78 @@ +======================================== +Maintenance Equipment Category Hierarchy +======================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:1c08bcf906560ac439e362f7cb2851d29e42b28a70bb64f3c086252012bdf491 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fmaintenance-lightgray.png?logo=github + :target: https://github.com/OCA/maintenance/tree/14.0/maintenance_equipment_category_hierarchy + :alt: OCA/maintenance +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/maintenance-14-0/maintenance-14-0-maintenance_equipment_category_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/maintenance&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + + +**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 +~~~~~~~ + +* CreuBlanca + +Contributors +~~~~~~~~~~~~ + +* Enric Tobella +* Jaime Arroyo +* Olga Marco +* Kevin Luna + +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/maintenance `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/maintenance_equipment_category_hierarchy/__init__.py b/maintenance_equipment_category_hierarchy/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/maintenance_equipment_category_hierarchy/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/maintenance_equipment_category_hierarchy/__manifest__.py b/maintenance_equipment_category_hierarchy/__manifest__.py new file mode 100644 index 000000000..925059235 --- /dev/null +++ b/maintenance_equipment_category_hierarchy/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2019 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Maintenance Equipment Category Hierarchy", + "summary": """ + Equipment Categories Hierarchy""", + "version": "14.0.1.0.0", + "license": "AGPL-3", + "author": "CreuBlanca, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/maintenance", + "depends": ["maintenance"], + "data": ["views/maintenance_equipment_category.xml"], +} diff --git a/maintenance_equipment_category_hierarchy/i18n/es.po b/maintenance_equipment_category_hierarchy/i18n/es.po new file mode 100644 index 000000000..55e068f24 --- /dev/null +++ b/maintenance_equipment_category_hierarchy/i18n/es.po @@ -0,0 +1,59 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * maintenance_equipment_category_hierarchy +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-12-12 12:05+0000\n" +"PO-Revision-Date: 2019-12-12 13:06+0100\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"Language: es\n" +"X-Generator: Poedit 2.0.6\n" + +#. module: maintenance_equipment_category_hierarchy +#: model:ir.model,name:maintenance_equipment_category_hierarchy.model_maintenance_equipment_category +msgid "Asset Category" +msgstr "Categoría de activo" + +#. module: maintenance_equipment_category_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_category_hierarchy.field_maintenance_equipment_category_child_id +msgid "Child Categories" +msgstr "Categorías hijas" + +#. module: maintenance_equipment_category_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_category_hierarchy.field_maintenance_equipment_category_complete_name +msgid "Complete Name" +msgstr "Nombre completo" + +#. module: maintenance_equipment_category_hierarchy +#: code:addons/maintenance_equipment_category_hierarchy/models/maintenance_equipment_category.py:49 +#, python-format +msgid "Error ! You cannot create recursive categories." +msgstr "Error ! No se pueden crear categorías cíclicas." + +#. module: maintenance_equipment_category_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_category_hierarchy.field_maintenance_equipment_category_parent_left +msgid "Left Parent" +msgstr "Padre izquierdo" + +#. module: maintenance_equipment_category_hierarchy +#: model:ir.ui.view,arch_db:maintenance_equipment_category_hierarchy.hr_equipment_category_view_form +msgid "Parent Categories" +msgstr "Categorías Padre" + +#. module: maintenance_equipment_category_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_category_hierarchy.field_maintenance_equipment_category_parent_id +msgid "Parent Category" +msgstr "Categoría Padre" + +#. module: maintenance_equipment_category_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_category_hierarchy.field_maintenance_equipment_category_parent_right +msgid "Right Parent" +msgstr "Padre derecho" diff --git a/maintenance_equipment_category_hierarchy/i18n/maintenance_equipment_category_hierarchy.pot b/maintenance_equipment_category_hierarchy/i18n/maintenance_equipment_category_hierarchy.pot new file mode 100644 index 000000000..32337d515 --- /dev/null +++ b/maintenance_equipment_category_hierarchy/i18n/maintenance_equipment_category_hierarchy.pot @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * maintenance_equipment_category_hierarchy +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-12-12 12:05+0000\n" +"PO-Revision-Date: 2019-12-12 12:05+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: maintenance_equipment_category_hierarchy +#: model:ir.model,name:maintenance_equipment_category_hierarchy.model_maintenance_equipment_category +msgid "Asset Category" +msgstr "" + +#. module: maintenance_equipment_category_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_category_hierarchy.field_maintenance_equipment_category_child_id +msgid "Child Categories" +msgstr "" + +#. module: maintenance_equipment_category_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_category_hierarchy.field_maintenance_equipment_category_complete_name +msgid "Complete Name" +msgstr "" + +#. module: maintenance_equipment_category_hierarchy +#: code:addons/maintenance_equipment_category_hierarchy/models/maintenance_equipment_category.py:49 +#, python-format +msgid "Error ! You cannot create recursive categories." +msgstr "" + +#. module: maintenance_equipment_category_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_category_hierarchy.field_maintenance_equipment_category_parent_left +msgid "Left Parent" +msgstr "" + +#. module: maintenance_equipment_category_hierarchy +#: model:ir.ui.view,arch_db:maintenance_equipment_category_hierarchy.hr_equipment_category_view_form +msgid "Parent Categories" +msgstr "" + +#. module: maintenance_equipment_category_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_category_hierarchy.field_maintenance_equipment_category_parent_id +msgid "Parent Category" +msgstr "" + +#. module: maintenance_equipment_category_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_category_hierarchy.field_maintenance_equipment_category_parent_right +msgid "Right Parent" +msgstr "" + diff --git a/maintenance_equipment_category_hierarchy/models/__init__.py b/maintenance_equipment_category_hierarchy/models/__init__.py new file mode 100644 index 000000000..da842f63b --- /dev/null +++ b/maintenance_equipment_category_hierarchy/models/__init__.py @@ -0,0 +1 @@ +from . import maintenance_equipment_category diff --git a/maintenance_equipment_category_hierarchy/models/maintenance_equipment_category.py b/maintenance_equipment_category_hierarchy/models/maintenance_equipment_category.py new file mode 100644 index 000000000..416dbc86e --- /dev/null +++ b/maintenance_equipment_category_hierarchy/models/maintenance_equipment_category.py @@ -0,0 +1,48 @@ +# Copyright 2019 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class MaintenanceEquipmentCategory(models.Model): + + _inherit = "maintenance.equipment.category" + + _parent_name = "parent_id" + _parent_store = True + _parent_order = "name" + _rec_name = "complete_name" + _order = "parent_id" + + complete_name = fields.Char( + "Complete Name", compute="_compute_complete_name", store=True + ) + + parent_id = fields.Many2one( + "maintenance.equipment.category", + "Parent Category", + index=True, + ondelete="cascade", + ) + child_id = fields.One2many( + "maintenance.equipment.category", "parent_id", "Child Categories" + ) + parent_path = fields.Char(index=True) + + @api.depends("name", "parent_id.complete_name") + def _compute_complete_name(self): + for category in self: + if category.parent_id: + category.complete_name = "{} / {}".format( + category.parent_id.complete_name, + category.name, + ) + else: + category.complete_name = category.name + + @api.constrains("parent_id") + def _check_category_recursion(self): + if not self._check_recursion(): + raise ValidationError(_("Error ! You cannot create recursive categories.")) + return True diff --git a/maintenance_equipment_category_hierarchy/readme/CONTRIBUTORS.rst b/maintenance_equipment_category_hierarchy/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..6b17bf9fa --- /dev/null +++ b/maintenance_equipment_category_hierarchy/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Enric Tobella +* Jaime Arroyo +* Olga Marco +* Kevin Luna diff --git a/maintenance_equipment_category_hierarchy/readme/DESCRIPTION.rst b/maintenance_equipment_category_hierarchy/readme/DESCRIPTION.rst new file mode 100644 index 000000000..e69de29bb diff --git a/maintenance_equipment_category_hierarchy/static/description/index.html b/maintenance_equipment_category_hierarchy/static/description/index.html new file mode 100644 index 000000000..c1f0bb3eb --- /dev/null +++ b/maintenance_equipment_category_hierarchy/static/description/index.html @@ -0,0 +1,423 @@ + + + + + + +Maintenance Equipment Category Hierarchy + + + +
+

Maintenance Equipment Category Hierarchy

+ + +

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

+

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

+
    +
  • CreuBlanca
  • +
+
+
+

Contributors

+
    +
  • Enric Tobella
  • +
  • Jaime Arroyo
  • +
  • Olga Marco
  • +
  • Kevin Luna
  • +
+
+
+

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

+

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

+
+
+
+ + diff --git a/maintenance_equipment_category_hierarchy/tests/__init__.py b/maintenance_equipment_category_hierarchy/tests/__init__.py new file mode 100644 index 000000000..6289c88d9 --- /dev/null +++ b/maintenance_equipment_category_hierarchy/tests/__init__.py @@ -0,0 +1 @@ +from . import test_maintenance_category diff --git a/maintenance_equipment_category_hierarchy/tests/test_maintenance_category.py b/maintenance_equipment_category_hierarchy/tests/test_maintenance_category.py new file mode 100644 index 000000000..4e38f7b3d --- /dev/null +++ b/maintenance_equipment_category_hierarchy/tests/test_maintenance_category.py @@ -0,0 +1,21 @@ +# Copyright 2019 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.exceptions import UserError +from odoo.tests.common import TransactionCase + + +class TestMaintenanceCategory(TransactionCase): + def setUp(self): + super().setUp() + self.category_1 = self.env["maintenance.equipment.category"].create( + {"name": "C1"} + ) + self.category_2 = self.env["maintenance.equipment.category"].create( + {"name": "C2", "parent_id": self.category_1.id} + ) + + def test_maintenance_category(self): + self.assertEqual(self.category_2.complete_name, "C1 / C2") + with self.assertRaises(UserError): + self.category_1.write({"parent_id": self.category_2.id}) diff --git a/maintenance_equipment_category_hierarchy/views/maintenance_equipment_category.xml b/maintenance_equipment_category_hierarchy/views/maintenance_equipment_category.xml new file mode 100644 index 000000000..e0910e586 --- /dev/null +++ b/maintenance_equipment_category_hierarchy/views/maintenance_equipment_category.xml @@ -0,0 +1,42 @@ + + + + + maintenance.equipment.category.tree (in maintenance_equipment_category_hierarchy) + maintenance.equipment.category + + + + + + + + + maintenance.equipment.category.form (in maintenance_equipment_category_hierarchy) + maintenance.equipment.category + + + + + + + + + + maintenance.request.search (in maintenance_location) + maintenance.request + + + + [('category_id', 'child_of', raw_value)] + + + + diff --git a/setup/maintenance_equipment_category_hierarchy/odoo/addons/maintenance_equipment_category_hierarchy b/setup/maintenance_equipment_category_hierarchy/odoo/addons/maintenance_equipment_category_hierarchy new file mode 120000 index 000000000..5a9af1643 --- /dev/null +++ b/setup/maintenance_equipment_category_hierarchy/odoo/addons/maintenance_equipment_category_hierarchy @@ -0,0 +1 @@ +../../../../maintenance_equipment_category_hierarchy \ No newline at end of file diff --git a/setup/maintenance_equipment_category_hierarchy/setup.py b/setup/maintenance_equipment_category_hierarchy/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/maintenance_equipment_category_hierarchy/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)