diff --git a/helpdesk_mgmt_maintenance/README.rst b/helpdesk_mgmt_maintenance/README.rst new file mode 100644 index 000000000..69147f6fa --- /dev/null +++ b/helpdesk_mgmt_maintenance/README.rst @@ -0,0 +1,77 @@ +============================ +Helpdesk Tickets Maintenance +============================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9ceb7a8c5c306f0dbd5f186fd5baa72a7ea4af363442ad13b7ea3c263acca8b7 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fhelpdesk-lightgray.png?logo=github + :target: https://github.com/OCA/helpdesk/tree/15.0/helpdesk_mgmt_maintenance + :alt: OCA/helpdesk +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/helpdesk-15-0/helpdesk-15-0-helpdesk_mgmt_maintenance + :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/helpdesk&target_branch=15.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module links helpdesk tickets with maintenance 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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Solvos + +Contributors +~~~~~~~~~~~~ + +* Ángel Rivas +* 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. + +This module is part of the `OCA/helpdesk `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/helpdesk_mgmt_maintenance/__init__.py b/helpdesk_mgmt_maintenance/__init__.py new file mode 100644 index 000000000..31660d6a9 --- /dev/null +++ b/helpdesk_mgmt_maintenance/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/helpdesk_mgmt_maintenance/__manifest__.py b/helpdesk_mgmt_maintenance/__manifest__.py new file mode 100644 index 000000000..c64cc0e1a --- /dev/null +++ b/helpdesk_mgmt_maintenance/__manifest__.py @@ -0,0 +1,18 @@ +# © 2024 Solvos Consultoría Informática () +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +{ + "name": "Helpdesk Tickets Maintenance", + "summary": "Links helpdesk tickets with maintenance equipments", + "version": "15.0.1.0.0", + "category": "After-Sales", + "website": "https://github.com/OCA/helpdesk", + "author": "Solvos, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["helpdesk_mgmt", "maintenance"], + "data": [ + "views/maintenance_equipment_views.xml", + "views/helpdesk_ticket_views.xml", + ], +} diff --git a/helpdesk_mgmt_maintenance/i18n/es.po b/helpdesk_mgmt_maintenance/i18n/es.po new file mode 100644 index 000000000..d77fc109e --- /dev/null +++ b/helpdesk_mgmt_maintenance/i18n/es.po @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * helpdesk_mgmt_maintenance +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-27 10:11+0000\n" +"PO-Revision-Date: 2024-10-27 10:11+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: helpdesk_mgmt_maintenance +#: model:ir.model.fields,field_description:helpdesk_mgmt_maintenance.field_maintenance_equipment__allow_ticket +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_maintenance.view_maintenance_equipment_form +msgid "Allow Tickets" +msgstr "Permite Solicitudes" + +#. module: helpdesk_mgmt_maintenance +#: model:ir.model.fields,field_description:helpdesk_mgmt_maintenance.field_helpdesk_ticket__equipment_ids +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_maintenance.view_helpdesk_ticket_form +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_maintenance.view_helpdesk_ticket_search +msgid "Equipments" +msgstr "Equipos" + +#. module: helpdesk_mgmt_maintenance +#: model:ir.model.fields,field_description:helpdesk_mgmt_maintenance.field_helpdesk_ticket__has_equipments +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_maintenance.view_helpdesk_ticket_search +msgid "Has Equipments" +msgstr "Tiene equipos" + +#. module: helpdesk_mgmt_maintenance +#: model:ir.model,name:helpdesk_mgmt_maintenance.model_helpdesk_ticket +msgid "Helpdesk Ticket" +msgstr "Solicitud del Servicio de Asistencia" + +#. module: helpdesk_mgmt_maintenance +#: model:ir.model,name:helpdesk_mgmt_maintenance.model_maintenance_equipment +msgid "Maintenance Equipment" +msgstr "Equipos de mantenimiento" + +#. module: helpdesk_mgmt_maintenance +#: model:ir.model.fields,field_description:helpdesk_mgmt_maintenance.field_maintenance_equipment__ticket_count +msgid "Number Tickets" +msgstr "Número de solicitudes" + +#. module: helpdesk_mgmt_maintenance +#: model:ir.model.fields,field_description:helpdesk_mgmt_maintenance.field_maintenance_equipment__ticket_ids +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_maintenance.view_maintenance_equipment_form +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_maintenance.view_maintenance_equipment_kanban +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_maintenance.view_maintenance_equipment_tree +msgid "Tickets" +msgstr "Solicitudes" diff --git a/helpdesk_mgmt_maintenance/i18n/helpdesk_mgmt_maintenance.pot b/helpdesk_mgmt_maintenance/i18n/helpdesk_mgmt_maintenance.pot new file mode 100644 index 000000000..84577f622 --- /dev/null +++ b/helpdesk_mgmt_maintenance/i18n/helpdesk_mgmt_maintenance.pot @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * helpdesk_mgmt_maintenance +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-27 10:11+0000\n" +"PO-Revision-Date: 2024-10-27 10:11+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: helpdesk_mgmt_maintenance +#: model:ir.model.fields,field_description:helpdesk_mgmt_maintenance.field_maintenance_equipment__allow_ticket +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_maintenance.view_maintenance_equipment_form +msgid "Allow Tickets" +msgstr "" + +#. module: helpdesk_mgmt_maintenance +#: model:ir.model.fields,field_description:helpdesk_mgmt_maintenance.field_helpdesk_ticket__equipment_ids +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_maintenance.view_helpdesk_ticket_form +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_maintenance.view_helpdesk_ticket_search +msgid "Equipments" +msgstr "" + +#. module: helpdesk_mgmt_maintenance +#: model:ir.model.fields,field_description:helpdesk_mgmt_maintenance.field_helpdesk_ticket__has_equipments +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_maintenance.view_helpdesk_ticket_search +msgid "Has Equipments" +msgstr "" + +#. module: helpdesk_mgmt_maintenance +#: model:ir.model,name:helpdesk_mgmt_maintenance.model_helpdesk_ticket +msgid "Helpdesk Ticket" +msgstr "" + +#. module: helpdesk_mgmt_maintenance +#: model:ir.model,name:helpdesk_mgmt_maintenance.model_maintenance_equipment +msgid "Maintenance Equipment" +msgstr "" + +#. module: helpdesk_mgmt_maintenance +#: model:ir.model.fields,field_description:helpdesk_mgmt_maintenance.field_maintenance_equipment__ticket_count +msgid "Number Tickets" +msgstr "" + +#. module: helpdesk_mgmt_maintenance +#: model:ir.model.fields,field_description:helpdesk_mgmt_maintenance.field_maintenance_equipment__ticket_ids +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_maintenance.view_maintenance_equipment_form +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_maintenance.view_maintenance_equipment_kanban +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_maintenance.view_maintenance_equipment_tree +msgid "Tickets" +msgstr "" diff --git a/helpdesk_mgmt_maintenance/models/__init__.py b/helpdesk_mgmt_maintenance/models/__init__.py new file mode 100644 index 000000000..cf1471875 --- /dev/null +++ b/helpdesk_mgmt_maintenance/models/__init__.py @@ -0,0 +1 @@ +from . import maintenance_equipment, helpdesk_ticket diff --git a/helpdesk_mgmt_maintenance/models/helpdesk_ticket.py b/helpdesk_mgmt_maintenance/models/helpdesk_ticket.py new file mode 100644 index 000000000..311b13124 --- /dev/null +++ b/helpdesk_mgmt_maintenance/models/helpdesk_ticket.py @@ -0,0 +1,24 @@ +# © 2024 Solvos Consultoría Informática () +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import api, fields, models + + +class HelpdeskTicket(models.Model): + _inherit = "helpdesk.ticket" + + equipment_ids = fields.Many2many( + "maintenance.equipment", + string="Equipments", + relation="helpdesk_ticket_maintenance_equipment_rel", + column1="helpdesk_ticket_id", + column2="maintenance_equipment_id", + copy=False, + ) + + has_equipments = fields.Boolean(store=True, compute="_compute_has_equipments") + + @api.depends("equipment_ids") + def _compute_has_equipments(self): + for ticket in self: + ticket.has_equipments = bool(ticket.equipment_ids) diff --git a/helpdesk_mgmt_maintenance/models/maintenance_equipment.py b/helpdesk_mgmt_maintenance/models/maintenance_equipment.py new file mode 100644 index 000000000..4be04553a --- /dev/null +++ b/helpdesk_mgmt_maintenance/models/maintenance_equipment.py @@ -0,0 +1,48 @@ +# © 2024 Solvos Consultoría Informática () +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import fields, models + + +class MaintenanceEquipment(models.Model): + _inherit = "maintenance.equipment" + + ticket_ids = fields.Many2many( + "helpdesk.ticket", + string="Tickets", + relation="helpdesk_ticket_maintenance_equipment_rel", + column1="maintenance_equipment_id", + column2="helpdesk_ticket_id", + copy=False, + ) + + allow_ticket = fields.Boolean(string="Allow Tickets", default=False) + + # NUMBERS TICKETS COMPUTE NO STORE + + ticket_count = fields.Integer( + string="Number Tickets", compute="_compute_ticket_count" + ) + + def _compute_ticket_count(self): + number_tickets = self.env["helpdesk.ticket"].read_group( + [("equipment_ids", "in", self.ids)], ["equipment_ids"], ["equipment_ids"] + ) + result = { + data["equipment_ids"][0]: data["equipment_ids_count"] + for data in number_tickets + } + for equipment in self: + equipment.ticket_count = result.get(equipment.id, 0) + + def action_view_tickets_equipment(self): + return { + "name": ("Tickets"), + "res_model": "helpdesk.ticket", + "view_mode": "tree,kanban,form", + "type": "ir.actions.act_window", + "domain": [("id", "in", self.ticket_ids.ids)], + "context": { + "default_equipment_ids": [(4, self.id)], + }, + } diff --git a/helpdesk_mgmt_maintenance/readme/CONTRIBUTORS.rst b/helpdesk_mgmt_maintenance/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..87e8aef5a --- /dev/null +++ b/helpdesk_mgmt_maintenance/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Ángel Rivas +* David Alonso diff --git a/helpdesk_mgmt_maintenance/readme/DESCRIPTION.rst b/helpdesk_mgmt_maintenance/readme/DESCRIPTION.rst new file mode 100644 index 000000000..76d86c8ac --- /dev/null +++ b/helpdesk_mgmt_maintenance/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module links helpdesk tickets with maintenance equipments. diff --git a/helpdesk_mgmt_maintenance/static/description/icon.png b/helpdesk_mgmt_maintenance/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/helpdesk_mgmt_maintenance/static/description/icon.png differ diff --git a/helpdesk_mgmt_maintenance/static/description/index.html b/helpdesk_mgmt_maintenance/static/description/index.html new file mode 100644 index 000000000..3ffe1b34c --- /dev/null +++ b/helpdesk_mgmt_maintenance/static/description/index.html @@ -0,0 +1,421 @@ + + + + + +Helpdesk Tickets Maintenance + + + +
+

Helpdesk Tickets Maintenance

+ + +

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

+

This module links helpdesk tickets with maintenance 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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Solvos
  • +
+
+
+

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.

+

This module is part of the OCA/helpdesk project on GitHub.

+

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

+
+
+
+ + diff --git a/helpdesk_mgmt_maintenance/tests/__init__.py b/helpdesk_mgmt_maintenance/tests/__init__.py new file mode 100644 index 000000000..832cbb75c --- /dev/null +++ b/helpdesk_mgmt_maintenance/tests/__init__.py @@ -0,0 +1 @@ +from . import test_helpdesk_mgmt_maintenance diff --git a/helpdesk_mgmt_maintenance/tests/test_helpdesk_mgmt_maintenance.py b/helpdesk_mgmt_maintenance/tests/test_helpdesk_mgmt_maintenance.py new file mode 100644 index 000000000..4e120549c --- /dev/null +++ b/helpdesk_mgmt_maintenance/tests/test_helpdesk_mgmt_maintenance.py @@ -0,0 +1,67 @@ +# © 2024 Solvos Consultoría Informática () +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + + +from odoo.tests import common +from odoo.tests.common import new_test_user, users + + +class TestHelpdeskMgmtMaintenance(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.user = new_test_user( + cls.env, + login="helpdesk-user", + groups="helpdesk_mgmt.group_helpdesk_user", + ) + cls.equipment1 = cls.env["maintenance.equipment"].create( + { + "name": "Test equipment 1", + "owner_user_id": cls.user.id, + "allow_ticket": True, + } + ) + cls.equipment2 = cls.env["maintenance.equipment"].create( + { + "name": "Test equipment 2", + "owner_user_id": cls.user.id, + "allow_ticket": True, + } + ) + cls.ticket1 = cls.env["helpdesk.ticket"].create( + { + "name": "Test ticket 1", + "description": "Test description 1", + } + ) + cls.ticket2 = cls.env["helpdesk.ticket"].create( + { + "name": "Test ticket 2", + "description": "Test description 2", + "equipment_ids": [(4, cls.equipment1.id), (4, cls.equipment2.id)], + } + ) + + @users("helpdesk-user") + def test_tickets(self): + self.assertFalse(self.ticket1.has_equipments) + self.assertTrue(self.ticket2.has_equipments) + + self.ticket1.equipment_ids = [(4, self.equipment1.id)] + self.assertTrue(self.ticket1.has_equipments) + + @users("helpdesk-user") + def test_equipments(self): + self.assertEqual(self.equipment1.ticket_count, 1) + self.assertEqual(self.equipment2.ticket_count, 1) + + self.ticket1.write({"equipment_ids": [(4, self.equipment1.id)]}) + self.equipment1.invalidate_cache() + self.assertEqual(self.equipment1.ticket_count, 2) + + action = self.equipment2.action_view_tickets_equipment() + self.assertEqual( + action["context"]["default_equipment_ids"], + [(4, self.equipment2.id)], + ) diff --git a/helpdesk_mgmt_maintenance/views/helpdesk_ticket_views.xml b/helpdesk_mgmt_maintenance/views/helpdesk_ticket_views.xml new file mode 100644 index 000000000..da9346ee1 --- /dev/null +++ b/helpdesk_mgmt_maintenance/views/helpdesk_ticket_views.xml @@ -0,0 +1,49 @@ + + + + helpdesk.ticket.form + helpdesk.ticket + + + + + + + + + + helpdesk.ticket.tree + helpdesk.ticket + + + + + + + + + + helpdesk.ticket.view.search + helpdesk.ticket + + + + + + + + + + + + + diff --git a/helpdesk_mgmt_maintenance/views/maintenance_equipment_views.xml b/helpdesk_mgmt_maintenance/views/maintenance_equipment_views.xml new file mode 100644 index 000000000..42481a82f --- /dev/null +++ b/helpdesk_mgmt_maintenance/views/maintenance_equipment_views.xml @@ -0,0 +1,63 @@ + + + + + maintenance.equipment.form + maintenance.equipment + + + + + + + + + + + + + maintenance.equipment.tree + maintenance.equipment + + + + + + + + + + maintenance.equipment.kanban + maintenance.equipment + + + + + + + + diff --git a/setup/helpdesk_mgmt_maintenance/odoo/addons/helpdesk_mgmt_maintenance b/setup/helpdesk_mgmt_maintenance/odoo/addons/helpdesk_mgmt_maintenance new file mode 120000 index 000000000..5c7d4fc8e --- /dev/null +++ b/setup/helpdesk_mgmt_maintenance/odoo/addons/helpdesk_mgmt_maintenance @@ -0,0 +1 @@ +../../../../helpdesk_mgmt_maintenance \ No newline at end of file diff --git a/setup/helpdesk_mgmt_maintenance/setup.py b/setup/helpdesk_mgmt_maintenance/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/helpdesk_mgmt_maintenance/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)