-
-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
454 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Allows you to link PO with maintenance requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
126 changes: 126 additions & 0 deletions
126
maintenance_request_purchase/i18n/maintenance_request_purchase.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import maintenance_request | ||
from . import purchase_order |
28 changes: 28 additions & 0 deletions
28
maintenance_request_purchase/models/maintenance_request.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
* Enric Tobella | ||
* Jaime Arroyo | ||
* Olga Marco | ||
* Núria Sancho |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This module allows to related a Maintenance Request with Purchase Orders |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_maintenance_purchase |
38 changes: 38 additions & 0 deletions
38
maintenance_request_purchase/tests/test_maintenance_purchase.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
Oops, something went wrong.