diff --git a/maintenance_equipment_hierarchy/README.rst b/maintenance_equipment_hierarchy/README.rst new file mode 100644 index 000000000..ba746b859 --- /dev/null +++ b/maintenance_equipment_hierarchy/README.rst @@ -0,0 +1,83 @@ +================================ +Maintenance Equipments Hierarchy +================================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmaintenance-lightgray.png?logo=github + :target: https://github.com/OCA/maintenance/tree/16.0/maintenance_equipment_hierarchy + :alt: OCA/maintenance +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/maintenance-15-0/maintenance-15-0-maintenance_equipment_hierarchy + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/240/16.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to manage a hierarchy of equipments. + +**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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Adrià Gil Sorribes +* Jordi Ballester Alomar +* David Alonso + +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-dalonsod| image:: https://github.com/dalonsod.png?size=40px + :target: https://github.com/dalonsod + :alt: dalonsod + +Current `maintainer `__: + +|maintainer-dalonsod| + +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_hierarchy/__init__.py b/maintenance_equipment_hierarchy/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/maintenance_equipment_hierarchy/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/maintenance_equipment_hierarchy/__manifest__.py b/maintenance_equipment_hierarchy/__manifest__.py new file mode 100644 index 000000000..832cb2654 --- /dev/null +++ b/maintenance_equipment_hierarchy/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2020 ForgeFlow S.L. (https://forgeflow.com) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +{ + "name": "Maintenance Equipments Hierarchy", + "summary": "Manage equipment hierarchy", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "maintainers": ["dalonsod"], + "website": "https://github.com/OCA/maintenance", + "category": "Equipments, Assets, Internal Hardware, Allocation Tracking", + "version": "16.0.1.0.0", + "license": "LGPL-3", + "depends": ["maintenance"], + "data": ["views/maintenance_equipment_views.xml"], + "demo": ["data/demo_maintenance_equipment_hierarchy.xml"], +} diff --git a/maintenance_equipment_hierarchy/data/demo_maintenance_equipment_hierarchy.xml b/maintenance_equipment_hierarchy/data/demo_maintenance_equipment_hierarchy.xml new file mode 100644 index 000000000..603d6e868 --- /dev/null +++ b/maintenance_equipment_hierarchy/data/demo_maintenance_equipment_hierarchy.xml @@ -0,0 +1,23 @@ + + + + HP Laptop battery + + + + + LP/303/28292090/BAT + 17-j059nr-bat + + + + HP Laptop case + + + + + LP/303/28292090/CAS + 17-j059nr-cas + + + diff --git a/maintenance_equipment_hierarchy/i18n/es.po b/maintenance_equipment_hierarchy/i18n/es.po new file mode 100644 index 000000000..a60c13dfa --- /dev/null +++ b/maintenance_equipment_hierarchy/i18n/es.po @@ -0,0 +1,81 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * maintenance_equipment_hierarchy +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2019-11-20 14:35+0000\n" +"Last-Translator: Jaime Arroyo \n" +"Language-Team: none\n" +"Language: es\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.8\n" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__child_ids +msgid "Child Equipments" +msgstr "Equipamientos Hijos" + +#. module: maintenance_equipment_hierarchy +#: model_terms:ir.ui.view,arch_db:maintenance_equipment_hierarchy.hr_equipment_view_form +msgid "Children" +msgstr "Hijos" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__complete_name +msgid "Complete Name" +msgstr "Nombre Completo" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__display_name +msgid "Display Name" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:maintenance.equipment,name:maintenance_equipment_hierarchy.equipment_computer9_1 +msgid "HP Laptop battery" +msgstr "Batería de Portátil HP" + +#. module: maintenance_equipment_hierarchy +#: model:maintenance.equipment,name:maintenance_equipment_hierarchy.equipment_computer9_2 +msgid "HP Laptop case" +msgstr "Funda de Portátil HP" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__parent_left +msgid "Left Parent" +msgstr "Padre Izquierdo" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model,name:maintenance_equipment_hierarchy.model_maintenance_equipment +#, fuzzy +msgid "Maintenance Equipment" +msgstr "Equipo Padre" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__child_count +msgid "Number of child equipments" +msgstr "Número de Equipamientos Hijos" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__parent_id +msgid "Parent Equipment" +msgstr "Equipo Padre" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__parent_path +msgid "Parent Path" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__parent_right +msgid "Right Parent" +msgstr "Padre derecho" + +#~ msgid "Equipment" +#~ msgstr "Equipamiento" diff --git a/maintenance_equipment_hierarchy/i18n/fr.po b/maintenance_equipment_hierarchy/i18n/fr.po new file mode 100644 index 000000000..0423a54b3 --- /dev/null +++ b/maintenance_equipment_hierarchy/i18n/fr.po @@ -0,0 +1,77 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * maintenance_equipment_hierarchy +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-03-19 15:46+0000\n" +"Last-Translator: Sandrine (ACSONE) \n" +"Language-Team: none\n" +"Language: fr_FR\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.3.2\n" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__child_ids +msgid "Child Equipments" +msgstr "Equipements enfants" + +#. module: maintenance_equipment_hierarchy +#: model_terms:ir.ui.view,arch_db:maintenance_equipment_hierarchy.hr_equipment_view_form +msgid "Children" +msgstr "Enfants" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__complete_name +msgid "Complete Name" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__display_name +msgid "Display Name" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:maintenance.equipment,name:maintenance_equipment_hierarchy.equipment_computer9_1 +msgid "HP Laptop battery" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:maintenance.equipment,name:maintenance_equipment_hierarchy.equipment_computer9_2 +msgid "HP Laptop case" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__parent_left +msgid "Left Parent" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model,name:maintenance_equipment_hierarchy.model_maintenance_equipment +msgid "Maintenance Equipment" +msgstr "Equipement" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__child_count +msgid "Number of child equipments" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__parent_id +msgid "Parent Equipment" +msgstr "Equipement parent" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__parent_path +msgid "Parent Path" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__parent_right +msgid "Right Parent" +msgstr "" diff --git a/maintenance_equipment_hierarchy/i18n/it.po b/maintenance_equipment_hierarchy/i18n/it.po new file mode 100644 index 000000000..ca5b3ddb5 --- /dev/null +++ b/maintenance_equipment_hierarchy/i18n/it.po @@ -0,0 +1,77 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * maintenance_equipment_hierarchy +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-07-28 09:49+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.3.2\n" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__child_ids +msgid "Child Equipments" +msgstr "Attrezzature discendenti" + +#. module: maintenance_equipment_hierarchy +#: model_terms:ir.ui.view,arch_db:maintenance_equipment_hierarchy.hr_equipment_view_form +msgid "Children" +msgstr "Discendente" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__complete_name +msgid "Complete Name" +msgstr "Nome completo" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: maintenance_equipment_hierarchy +#: model:maintenance.equipment,name:maintenance_equipment_hierarchy.equipment_computer9_1 +msgid "HP Laptop battery" +msgstr "Batteria laptop HP" + +#. module: maintenance_equipment_hierarchy +#: model:maintenance.equipment,name:maintenance_equipment_hierarchy.equipment_computer9_2 +msgid "HP Laptop case" +msgstr "Case laptop HP" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__parent_left +msgid "Left Parent" +msgstr "Ascendente precedente" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model,name:maintenance_equipment_hierarchy.model_maintenance_equipment +msgid "Maintenance Equipment" +msgstr "Attrezzatura manutenzione" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__child_count +msgid "Number of child equipments" +msgstr "Numero di attrezzature discendenti" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__parent_id +msgid "Parent Equipment" +msgstr "Attrezzatura ascendente" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__parent_path +msgid "Parent Path" +msgstr "Percorso ascendente" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__parent_right +msgid "Right Parent" +msgstr "Ascendente successivo" diff --git a/maintenance_equipment_hierarchy/i18n/maintenance_equipment_hierarchy.pot b/maintenance_equipment_hierarchy/i18n/maintenance_equipment_hierarchy.pot new file mode 100644 index 000000000..dea3b1b5c --- /dev/null +++ b/maintenance_equipment_hierarchy/i18n/maintenance_equipment_hierarchy.pot @@ -0,0 +1,80 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * maintenance_equipment_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: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__child_ids +msgid "Child Equipments" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: code:addons/maintenance_equipment_hierarchy/models/maintenance_equipment.py:0 +#, python-format +msgid "Child equipment of %s" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model_terms:ir.ui.view,arch_db:maintenance_equipment_hierarchy.hr_equipment_view_form +msgid "Children" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__complete_name +msgid "Complete Name" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__display_name +msgid "Display Name" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:maintenance.equipment,name:maintenance_equipment_hierarchy.equipment_computer9_1 +msgid "HP Laptop battery" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:maintenance.equipment,name:maintenance_equipment_hierarchy.equipment_computer9_2 +msgid "HP Laptop case" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__parent_left +msgid "Left Parent" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model,name:maintenance_equipment_hierarchy.model_maintenance_equipment +msgid "Maintenance Equipment" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__child_count +msgid "Number of child equipments" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__parent_id +msgid "Parent Equipment" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__parent_path +msgid "Parent Path" +msgstr "" + +#. module: maintenance_equipment_hierarchy +#: model:ir.model.fields,field_description:maintenance_equipment_hierarchy.field_maintenance_equipment__parent_right +msgid "Right Parent" +msgstr "" diff --git a/maintenance_equipment_hierarchy/models/__init__.py b/maintenance_equipment_hierarchy/models/__init__.py new file mode 100644 index 000000000..e960c415c --- /dev/null +++ b/maintenance_equipment_hierarchy/models/__init__.py @@ -0,0 +1 @@ +from . import maintenance_equipment diff --git a/maintenance_equipment_hierarchy/models/maintenance_equipment.py b/maintenance_equipment_hierarchy/models/maintenance_equipment.py new file mode 100644 index 000000000..8a98774dd --- /dev/null +++ b/maintenance_equipment_hierarchy/models/maintenance_equipment.py @@ -0,0 +1,69 @@ +# Copyright 2020 ForgeFlow S.L. (https://forgeflow.com) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo import _, api, fields, models + + +class MaintenanceEquipment(models.Model): + + _inherit = "maintenance.equipment" + _parent_name = "parent_id" + _parent_store = True + _parent_order = "name" + + parent_id = fields.Many2one( + "maintenance.equipment", + "Parent Equipment", + index=True, + ondelete="cascade", + tracking=True, + ) + child_ids = fields.One2many( + "maintenance.equipment", "parent_id", "Child Equipments" + ) + parent_left = fields.Integer("Left Parent", index=1) + parent_right = fields.Integer("Right Parent", index=1) + child_count = fields.Integer( + compute="_compute_child_count", string="Number of child equipments" + ) + display_name = fields.Char(compute="_compute_display_name") + complete_name = fields.Char( + compute="_compute_complete_name", store=True, recursive=True + ) + parent_path = fields.Char(index=True) + + def name_get(self): + return [(equipment.id, equipment.complete_name) for equipment in self] + + @api.depends("child_ids") + def _compute_child_count(self): + for equipment in self: + equipment.child_count = len(equipment.child_ids) + + def _compute_display_name(self): + for equipment in self: + equipment.display_name = equipment.complete_name + + @api.depends("name", "parent_id.complete_name") # recursive definition + def _compute_complete_name(self): + for equipment in self: + if equipment.parent_id: + parent_name = equipment.parent_id.complete_name + equipment.complete_name = parent_name + " / " + equipment.name + else: + equipment.complete_name = equipment.name + + def preview_child_list(self): + return { + "name": _("Child equipment of %s") % self.name, + "type": "ir.actions.act_window", + "res_model": "maintenance.equipment", + "res_id": self.id, + "view_mode": "list,form", + "context": { + **self.env.context, + "default_parent_id": self.id, + "parent_id_editable": False, + }, + "domain": [("parent_id", "=", self.id)], + } diff --git a/maintenance_equipment_hierarchy/readme/CONTRIBUTORS.rst b/maintenance_equipment_hierarchy/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..6ae5792fe --- /dev/null +++ b/maintenance_equipment_hierarchy/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Adrià Gil Sorribes +* Jordi Ballester Alomar +* David Alonso diff --git a/maintenance_equipment_hierarchy/readme/DESCRIPTION.rst b/maintenance_equipment_hierarchy/readme/DESCRIPTION.rst new file mode 100644 index 000000000..c561adda8 --- /dev/null +++ b/maintenance_equipment_hierarchy/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to manage a hierarchy of equipments. diff --git a/maintenance_equipment_hierarchy/static/description/icon.png b/maintenance_equipment_hierarchy/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/maintenance_equipment_hierarchy/static/description/icon.png differ diff --git a/maintenance_equipment_hierarchy/static/description/index.html b/maintenance_equipment_hierarchy/static/description/index.html new file mode 100644 index 000000000..87081d2e3 --- /dev/null +++ b/maintenance_equipment_hierarchy/static/description/index.html @@ -0,0 +1,423 @@ + + + + + + +Maintenance Equipments Hierarchy + + + +
+

Maintenance Equipments Hierarchy

+ + +

Beta License: LGPL-3 OCA/maintenance Translate me on Weblate Try me on Runbot

+

This module allows to manage a hierarchy of equipments.

+

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 smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

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:

+

dalonsod

+

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_hierarchy/tests/__init__.py b/maintenance_equipment_hierarchy/tests/__init__.py new file mode 100644 index 000000000..08989b9f2 --- /dev/null +++ b/maintenance_equipment_hierarchy/tests/__init__.py @@ -0,0 +1 @@ +from . import test_maintenance_equipment_hierarchy diff --git a/maintenance_equipment_hierarchy/tests/test_maintenance_equipment_hierarchy.py b/maintenance_equipment_hierarchy/tests/test_maintenance_equipment_hierarchy.py new file mode 100644 index 000000000..fe6c0dfdf --- /dev/null +++ b/maintenance_equipment_hierarchy/tests/test_maintenance_equipment_hierarchy.py @@ -0,0 +1,37 @@ +# Copyright 2020 ForgeFlow S.L. (https://forgeflow.com) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo.exceptions import UserError +from odoo.tests import common + + +class TestMaintenanceEquipmentHierarchy(common.TransactionCase): + def setUp(self): + super(TestMaintenanceEquipmentHierarchy, self).setUp() + self.Equipment = self.env["maintenance.equipment"] + self.equipment1 = self.Equipment.create({"name": "Equipment 1"}) + + self.equipment1_1 = self.Equipment.create({"name": "Equipment 1.1"}) + + def test_01_hierarchy(self): + self.equipment1_1.parent_id = self.equipment1 + res = self.equipment1.preview_child_list() + self.assertEqual(res["domain"], [("parent_id", "=", self.equipment1.id)]) + + def test_02_recursion(self): + with self.assertRaises(UserError): + self.equipment1.parent_id = self.equipment1 + + def test_03_name_get_display_complete(self): + self.equipment1_1.parent_id = self.equipment1 + equipment1_1_complete_name = ( + self.equipment1.name + " / " + self.equipment1_1.name + ) + + self.assertEqual(self.equipment1.name_get()[0][1], self.equipment1.name) + self.assertEqual(self.equipment1.complete_name, self.equipment1.name) + self.assertEqual(self.equipment1.display_name, self.equipment1.name) + + self.assertEqual(self.equipment1_1.name_get()[0][1], equipment1_1_complete_name) + self.assertEqual(self.equipment1_1.complete_name, equipment1_1_complete_name) + self.assertEqual(self.equipment1_1.display_name, equipment1_1_complete_name) diff --git a/maintenance_equipment_hierarchy/views/maintenance_equipment_views.xml b/maintenance_equipment_hierarchy/views/maintenance_equipment_views.xml new file mode 100644 index 000000000..8a577eea2 --- /dev/null +++ b/maintenance_equipment_hierarchy/views/maintenance_equipment_views.xml @@ -0,0 +1,51 @@ + + + + equipment.form + maintenance.equipment + + +
+ +
+ + + + +
+ + equipment.tree + maintenance.equipment + + + + + + + + + equipment.search + maintenance.equipment + + + + ['|','|','|',('complete_name','ilike',self),('model','ilike',self),('serial_no','ilike',self),('partner_ref', 'ilike', self)] + + + +
diff --git a/setup/maintenance_equipment_hierarchy/odoo/addons/maintenance_equipment_hierarchy b/setup/maintenance_equipment_hierarchy/odoo/addons/maintenance_equipment_hierarchy new file mode 120000 index 000000000..66d446577 --- /dev/null +++ b/setup/maintenance_equipment_hierarchy/odoo/addons/maintenance_equipment_hierarchy @@ -0,0 +1 @@ +../../../../maintenance_equipment_hierarchy \ No newline at end of file diff --git a/setup/maintenance_equipment_hierarchy/setup.py b/setup/maintenance_equipment_hierarchy/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/maintenance_equipment_hierarchy/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)