diff --git a/maintenance_request_purchase/README.rst b/maintenance_request_purchase/README.rst
new file mode 100644
index 000000000..cc77b7fc9
--- /dev/null
+++ b/maintenance_request_purchase/README.rst
@@ -0,0 +1 @@
+Allows you to link PO with maintenance requests
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..7a83164ce
--- /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": "14.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/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/maintenance_request_purchase.pot b/maintenance_request_purchase/i18n/maintenance_request_purchase.pot
new file mode 100644
index 000000000..fcec286df
--- /dev/null
+++ b/maintenance_request_purchase/i18n/maintenance_request_purchase.pot
@@ -0,0 +1,126 @@
+# 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 11:51+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_request_purchase
+#: model:ir.ui.view,arch_db:maintenance_request_purchase.wizard_link_maintenance_po_form_view
+msgid "Cancel"
+msgstr ""
+
+#. module: maintenance_request_purchase
+#: model:ir.model.fields,field_description:maintenance_request_purchase.field_wizard_link_maintenance_po_create_uid
+msgid "Created by"
+msgstr ""
+
+#. module: maintenance_request_purchase
+#: model:ir.model.fields,field_description:maintenance_request_purchase.field_wizard_link_maintenance_po_create_date
+msgid "Created on"
+msgstr ""
+
+#. module: maintenance_request_purchase
+#: model:ir.model.fields,field_description:maintenance_request_purchase.field_wizard_link_maintenance_po_display_name
+msgid "Display Name"
+msgstr ""
+
+#. module: maintenance_request_purchase
+#: model:ir.model.fields,field_description:maintenance_request_purchase.field_wizard_link_maintenance_po_id
+msgid "ID"
+msgstr ""
+
+#. 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 ""
+
+#. 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 ""
+
+#. 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 ""
+
+#. 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 ""
+
+#. 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 ""
+
+#. module: maintenance_request_purchase
+#: model:ir.ui.view,arch_db:maintenance_request_purchase.purchase_order_form
+msgid "Maintenance"
+msgstr ""
+
+#. 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 ""
+
+#. 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 ""
+
+#. 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.ui.view,arch_db:maintenance_request_purchase.wizard_link_maintenance_po_form_view
+msgid "New Purchase Order"
+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:ir.model.fields,field_description:maintenance_request_purchase.field_wizard_link_maintenance_po_purchase_order_ids
+msgid "Purchase Orders"
+msgstr ""
+
+#. module: maintenance_request_purchase
+#: model:ir.ui.view,arch_db:maintenance_request_purchase.hr_equipment_request_view_form_button_box
+msgid "Purchases"
+msgstr ""
+
+#. module: maintenance_request_purchase
+#: model:ir.model.fields,field_description:maintenance_request_purchase.field_maintenance_request_purchases_count
+msgid "Purchases Count"
+msgstr ""
+
+#. 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 ""
+
+#. module: maintenance_request_purchase
+#: model:ir.model,name:maintenance_request_purchase.model_wizard_link_maintenance_po
+msgid "wizard.link.maintenance.po"
+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..de0bf2149
--- /dev/null
+++ b/maintenance_request_purchase/models/maintenance_request.py
@@ -0,0 +1,28 @@
+# 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",
+ )
+ 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..411232002
--- /dev/null
+++ b/maintenance_request_purchase/models/purchase_order.py
@@ -0,0 +1,38 @@
+# 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",
+ )
+
+ 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/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..d9a536c48
--- /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 SavepointCase
+
+
+class TestMaintenancePurchase(SavepointCase):
+ @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..edd3b2fdf
--- /dev/null
+++ b/maintenance_request_purchase/views/maintenance_request.xml
@@ -0,0 +1,20 @@
+
+
+
+
+ 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,
+)