diff --git a/maintenance_request_purchase/README.rst b/maintenance_request_purchase/README.rst new file mode 100644 index 000000000..d827ab8b6 --- /dev/null +++ b/maintenance_request_purchase/README.rst @@ -0,0 +1,80 @@ +============================ +Maintenance Request Purchase +============================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:7b5844243a0844f36cb8ae52aa44f140202120be2e6d867cde7e38922014e5e1 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/16.0/maintenance_request_purchase + :alt: OCA/maintenance +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/maintenance-16-0/maintenance-16-0-maintenance_request_purchase + :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=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to related a Maintenance Request with Purchase Orders + +**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 +* Dixmit + +Contributors +~~~~~~~~~~~~ + +* Enric Tobella +* Jaime Arroyo +* Olga Marco +* Núria Sancho + +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_request_purchase/__init__.py b/maintenance_request_purchase/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/maintenance_request_purchase/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/maintenance_request_purchase/__manifest__.py b/maintenance_request_purchase/__manifest__.py new file mode 100644 index 000000000..e2b37f1c0 --- /dev/null +++ b/maintenance_request_purchase/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2019 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Maintenance Request Purchase", + "summary": """ + Allows you to link PO with maintenance requests""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "CreuBlanca,Dixmit,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/maintenance", + "depends": ["base_maintenance", "purchase"], + "data": [ + "views/maintenance_request.xml", + "views/purchase_order_views.xml", + ], +} diff --git a/maintenance_request_purchase/i18n/ca.po b/maintenance_request_purchase/i18n/ca.po new file mode 100644 index 000000000..ad1582a3b --- /dev/null +++ b/maintenance_request_purchase/i18n/ca.po @@ -0,0 +1,71 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * maintenance_request_purchase +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-15 18:36+0000\n" +"Last-Translator: Enric Tobella \n" +"Language-Team: none\n" +"Language: ca\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.17\n" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request__display_name +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order__display_name +msgid "Display Name" +msgstr "Nom a mostrar" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request__id +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order__id +msgid "ID" +msgstr "ID" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request____last_update +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order____last_update +msgid "Last Modified on" +msgstr "Última modificació el" + +#. module: maintenance_request_purchase +#: model_terms:ir.ui.view,arch_db:maintenance_request_purchase.purchase_order_form +msgid "Maintenance" +msgstr "Manteniment" + +#. module: maintenance_request_purchase +#: model:ir.model,name:maintenance_request_purchase.model_maintenance_request +msgid "Maintenance Request" +msgstr "Petició de manteniment" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order__maintenance_request_ids +msgid "Maintenance Requests" +msgstr "Peticions de manteniment" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order__maintenance_requests_count +msgid "Maintenance Requests Count" +msgstr "Nombre de peticions de manteniment" + +#. module: maintenance_request_purchase +#: model:ir.model,name:maintenance_request_purchase.model_purchase_order +msgid "Purchase Order" +msgstr "Comanda de compra" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request__purchase_order_ids +#: model_terms:ir.ui.view,arch_db:maintenance_request_purchase.hr_equipment_request_view_form_button_box +msgid "Purchase Orders" +msgstr "Comandes de compra" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request__purchases_count +msgid "Purchases Count" +msgstr "Nombre de comandes" diff --git a/maintenance_request_purchase/i18n/es.po b/maintenance_request_purchase/i18n/es.po new file mode 100644 index 000000000..074110a73 --- /dev/null +++ b/maintenance_request_purchase/i18n/es.po @@ -0,0 +1,127 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * maintenance_request_purchase +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-12-12 11:51+0000\n" +"PO-Revision-Date: 2019-12-12 12:54+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_request_purchase +#: model:ir.ui.view,arch_db:maintenance_request_purchase.wizard_link_maintenance_po_form_view +msgid "Cancel" +msgstr "Cancelar" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_wizard_link_maintenance_po_create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_wizard_link_maintenance_po_create_date +msgid "Created on" +msgstr "Creado en" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_wizard_link_maintenance_po_display_name +msgid "Display Name" +msgstr "Nombre mostrado" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_wizard_link_maintenance_po_id +msgid "ID" +msgstr "ID (identificación)" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_wizard_link_maintenance_po___last_update +msgid "Last Modified on" +msgstr "Última modificación en" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_wizard_link_maintenance_po_write_uid +msgid "Last Updated by" +msgstr "Última actualización de" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_wizard_link_maintenance_po_write_date +msgid "Last Updated on" +msgstr "Última actualización en" + +#. module: maintenance_request_purchase +#: model:ir.ui.view,arch_db:maintenance_request_purchase.wizard_link_maintenance_po_form_view +msgid "Link Selected Purchase Orders" +msgstr "Relacionar órdenes de compra seleccionadas" + +#. module: maintenance_request_purchase +#: model:ir.actions.act_window,name:maintenance_request_purchase.wizard_link_maintenance_po_act_window +#: model:ir.ui.view,arch_db:maintenance_request_purchase.hr_equipment_request_view_form +#: model:ir.ui.view,arch_db:maintenance_request_purchase.wizard_link_maintenance_po_form_view +msgid "Link to PO" +msgstr "Relacionar con PO" + +#. module: maintenance_request_purchase +#: model:ir.ui.view,arch_db:maintenance_request_purchase.purchase_order_form +msgid "Maintenance" +msgstr "Mantenimiento" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_wizard_link_maintenance_po_maintenance_request_id +msgid "Maintenance Request" +msgstr "Petición de Mantenimiento" + +#. module: maintenance_request_purchase +#: model:ir.model,name:maintenance_request_purchase.model_maintenance_request +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order_maintenance_request_ids +msgid "Maintenance Requests" +msgstr "Peticiones de Mantenimiento" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order_maintenance_requests_count +msgid "Maintenance Requests Count" +msgstr "Número de Peticiones de Mantenimiento" + +#. module: maintenance_request_purchase +#: model:ir.ui.view,arch_db:maintenance_request_purchase.wizard_link_maintenance_po_form_view +msgid "New Purchase Order" +msgstr "Nueva Orden de Compra" + +#. module: maintenance_request_purchase +#: model:ir.model,name:maintenance_request_purchase.model_purchase_order +msgid "Purchase Order" +msgstr "Pedido de compra" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request_purchase_order_ids +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_wizard_link_maintenance_po_purchase_order_ids +msgid "Purchase Orders" +msgstr "Pedidos de compra" + +#. module: maintenance_request_purchase +#: model:ir.ui.view,arch_db:maintenance_request_purchase.hr_equipment_request_view_form_button_box +msgid "Purchases" +msgstr "Compras" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request_purchases_count +msgid "Purchases Count" +msgstr "Número de Compras" + +#. module: maintenance_request_purchase +#: model:ir.ui.view,arch_db:maintenance_request_purchase.wizard_link_maintenance_po_form_view +msgid "Select Purchase Orders and Link them or Create a new Purchase Order" +msgstr "Selecciona órdenes de compra para relacionarlas con la petición o crea una nueva" + +#. module: maintenance_request_purchase +#: model:ir.model,name:maintenance_request_purchase.model_wizard_link_maintenance_po +msgid "wizard.link.maintenance.po" +msgstr "wizard.link.maintenance.po" diff --git a/maintenance_request_purchase/i18n/it.po b/maintenance_request_purchase/i18n/it.po new file mode 100644 index 000000000..a54abc1a6 --- /dev/null +++ b/maintenance_request_purchase/i18n/it.po @@ -0,0 +1,71 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * maintenance_request_purchase +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-10-28 13:20+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.17\n" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request__display_name +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request__id +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order__id +msgid "ID" +msgstr "ID" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request____last_update +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: maintenance_request_purchase +#: model_terms:ir.ui.view,arch_db:maintenance_request_purchase.purchase_order_form +msgid "Maintenance" +msgstr "Manutenzione" + +#. module: maintenance_request_purchase +#: model:ir.model,name:maintenance_request_purchase.model_maintenance_request +msgid "Maintenance Request" +msgstr "Richiesta manutenzione" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order__maintenance_request_ids +msgid "Maintenance Requests" +msgstr "Richieste manutenzione" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order__maintenance_requests_count +msgid "Maintenance Requests Count" +msgstr "Conta richieste manutenzione" + +#. module: maintenance_request_purchase +#: model:ir.model,name:maintenance_request_purchase.model_purchase_order +msgid "Purchase Order" +msgstr "Ordine di acquisto" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request__purchase_order_ids +#: model_terms:ir.ui.view,arch_db:maintenance_request_purchase.hr_equipment_request_view_form_button_box +msgid "Purchase Orders" +msgstr "Ordini di acquisto" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request__purchases_count +msgid "Purchases Count" +msgstr "Conteggio acquisti" diff --git a/maintenance_request_purchase/i18n/maintenance_request_purchase.pot b/maintenance_request_purchase/i18n/maintenance_request_purchase.pot new file mode 100644 index 000000000..0b303f3b7 --- /dev/null +++ b/maintenance_request_purchase/i18n/maintenance_request_purchase.pot @@ -0,0 +1,68 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * maintenance_request_purchase +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.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_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request__display_name +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order__display_name +msgid "Display Name" +msgstr "" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request__id +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order__id +msgid "ID" +msgstr "" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request____last_update +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order____last_update +msgid "Last Modified on" +msgstr "" + +#. module: maintenance_request_purchase +#: model_terms:ir.ui.view,arch_db:maintenance_request_purchase.purchase_order_form +msgid "Maintenance" +msgstr "" + +#. module: maintenance_request_purchase +#: model:ir.model,name:maintenance_request_purchase.model_maintenance_request +msgid "Maintenance Request" +msgstr "" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order__maintenance_request_ids +msgid "Maintenance Requests" +msgstr "" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_purchase_order__maintenance_requests_count +msgid "Maintenance Requests Count" +msgstr "" + +#. module: maintenance_request_purchase +#: model:ir.model,name:maintenance_request_purchase.model_purchase_order +msgid "Purchase Order" +msgstr "" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request__purchase_order_ids +#: model_terms:ir.ui.view,arch_db:maintenance_request_purchase.hr_equipment_request_view_form_button_box +msgid "Purchase Orders" +msgstr "" + +#. module: maintenance_request_purchase +#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request__purchases_count +msgid "Purchases Count" +msgstr "" diff --git a/maintenance_request_purchase/models/__init__.py b/maintenance_request_purchase/models/__init__.py new file mode 100644 index 000000000..e1f528445 --- /dev/null +++ b/maintenance_request_purchase/models/__init__.py @@ -0,0 +1,2 @@ +from . import maintenance_request +from . import purchase_order diff --git a/maintenance_request_purchase/models/maintenance_request.py b/maintenance_request_purchase/models/maintenance_request.py new file mode 100644 index 000000000..1949bc518 --- /dev/null +++ b/maintenance_request_purchase/models/maintenance_request.py @@ -0,0 +1,29 @@ +# Copyright 2019 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class MaintenanceRequest(models.Model): + + _inherit = "maintenance.request" + + purchase_order_ids = fields.Many2many( + "purchase.order", + "maintenance_purchase_order", + "maintenance_request_id", + "purchase_order_id", + groups="purchase.group_purchase_user", + string="Purchase Orders", + copy=False, + ) + purchases_count = fields.Integer( + compute="_compute_purchases_count", + store=True, + groups="purchase.group_purchase_user", + ) + + @api.depends("purchase_order_ids") + def _compute_purchases_count(self): + for record in self: + record.purchases_count = len(record.purchase_order_ids.ids) diff --git a/maintenance_request_purchase/models/purchase_order.py b/maintenance_request_purchase/models/purchase_order.py new file mode 100644 index 000000000..b8eebe6d7 --- /dev/null +++ b/maintenance_request_purchase/models/purchase_order.py @@ -0,0 +1,39 @@ +# Copyright 2019 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class PurchaseOrder(models.Model): + + _inherit = "purchase.order" + + maintenance_request_ids = fields.Many2many( + "maintenance.request", + "maintenance_purchase_order", + "purchase_order_id", + "maintenance_request_id", + string="Maintenance Requests", + copy=False, + ) + + maintenance_requests_count = fields.Integer( + compute="_compute_maintenance_requests_count", store=True + ) + + @api.depends("maintenance_request_ids") + def _compute_maintenance_requests_count(self): + for record in self: + record.maintenance_requests_count = len(record.maintenance_request_ids.ids) + + def action_view_maintenance_request(self): + action = self.env["ir.actions.act_window"]._for_xml_id( + "maintenance.hr_equipment_request_action" + ) + if len(self.maintenance_request_ids) > 1: + action["domain"] = [("id", "in", self.maintenance_request_ids.ids)] + elif self.maintenance_request_ids: + action["views"] = [(False, "form")] + action["res_id"] = self.maintenance_request_ids.id + action["context"] = {} + return action diff --git a/maintenance_request_purchase/readme/CONTRIBUTORS.rst b/maintenance_request_purchase/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..0c8996032 --- /dev/null +++ b/maintenance_request_purchase/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Enric Tobella +* Jaime Arroyo +* Olga Marco +* Núria Sancho diff --git a/maintenance_request_purchase/readme/DESCRIPTION.rst b/maintenance_request_purchase/readme/DESCRIPTION.rst new file mode 100644 index 000000000..b0ec4d4fb --- /dev/null +++ b/maintenance_request_purchase/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to related a Maintenance Request with Purchase Orders diff --git a/maintenance_request_purchase/static/description/icon.png b/maintenance_request_purchase/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/maintenance_request_purchase/static/description/icon.png differ diff --git a/maintenance_request_purchase/static/description/index.html b/maintenance_request_purchase/static/description/index.html new file mode 100644 index 000000000..b0daeacf9 --- /dev/null +++ b/maintenance_request_purchase/static/description/index.html @@ -0,0 +1,425 @@ + + + + + + +Maintenance Request Purchase + + + +
+

Maintenance Request Purchase

+ + +

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

+

This module allows to related a Maintenance Request with Purchase Orders

+

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
  • +
  • Dixmit
  • +
+
+
+

Contributors

+
    +
  • Enric Tobella
  • +
  • Jaime Arroyo
  • +
  • Olga Marco
  • +
  • Núria Sancho
  • +
+
+
+

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_request_purchase/tests/__init__.py b/maintenance_request_purchase/tests/__init__.py new file mode 100644 index 000000000..5d9f08d20 --- /dev/null +++ b/maintenance_request_purchase/tests/__init__.py @@ -0,0 +1 @@ +from . import test_maintenance_purchase diff --git a/maintenance_request_purchase/tests/test_maintenance_purchase.py b/maintenance_request_purchase/tests/test_maintenance_purchase.py new file mode 100644 index 000000000..12cc452d7 --- /dev/null +++ b/maintenance_request_purchase/tests/test_maintenance_purchase.py @@ -0,0 +1,38 @@ +# Copyright 2023 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestMaintenancePurchase(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.team_id = cls.env["maintenance.team"].create({"name": "Maintenance Team"}) + cls.request_1 = cls.env["maintenance.request"].create( + {"name": "Req 1", "maintenance_team_id": cls.team_id.id} + ) + cls.request_2 = cls.env["maintenance.request"].create( + {"name": "Req 1", "maintenance_team_id": cls.team_id.id} + ) + cls.supplier = cls.env["res.partner"].create({"name": "Supplier"}) + cls.po_1 = cls.env["purchase.order"].create( + { + "partner_id": cls.supplier.id, + "date_planned": "2017-02-11 22:00:00", + } + ) + + def test_maintenance_purchase(self): + self.assertEqual(self.request_1.purchases_count, 0) + self.assertEqual(self.po_1.maintenance_requests_count, 0) + self.request_1.purchase_order_ids = self.po_1 + self.assertEqual(self.request_1.purchases_count, 1) + self.assertEqual(self.po_1.maintenance_requests_count, 1) + action = self.po_1.action_view_maintenance_request() + self.assertEqual(action["res_id"], self.request_1.id) + self.request_2.write({"purchase_order_ids": [(4, self.po_1.id)]}) + action = self.po_1.action_view_maintenance_request() + requests = self.env[action["res_model"]].search(action["domain"]) + self.assertIn(self.request_1, requests) + self.assertIn(self.request_2, requests) diff --git a/maintenance_request_purchase/views/maintenance_request.xml b/maintenance_request_purchase/views/maintenance_request.xml new file mode 100644 index 000000000..d8338c730 --- /dev/null +++ b/maintenance_request_purchase/views/maintenance_request.xml @@ -0,0 +1,23 @@ + + + + + maintenance.request.form (in maintenance_equipment_purchase) + maintenance.request + + + + + + + + + + diff --git a/maintenance_request_purchase/views/purchase_order_views.xml b/maintenance_request_purchase/views/purchase_order_views.xml new file mode 100644 index 000000000..3748d3369 --- /dev/null +++ b/maintenance_request_purchase/views/purchase_order_views.xml @@ -0,0 +1,43 @@ + + + + + purchase.order.form (in maintenance_equipment_purchase) + purchase.order + + +
+ + +
+
+
+ + purchase.order.line.search (in maintenance_equipment_purchase) + purchase.order.line + + + + + + + +
diff --git a/setup/maintenance_request_purchase/odoo/addons/maintenance_request_purchase b/setup/maintenance_request_purchase/odoo/addons/maintenance_request_purchase new file mode 120000 index 000000000..91c9a8aed --- /dev/null +++ b/setup/maintenance_request_purchase/odoo/addons/maintenance_request_purchase @@ -0,0 +1 @@ +../../../../maintenance_request_purchase \ No newline at end of file diff --git a/setup/maintenance_request_purchase/setup.py b/setup/maintenance_request_purchase/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/maintenance_request_purchase/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)