[MIG] maintenance_create_requests_from_project_task: Migration to 18.0

This commit is contained in:
Stéphan Sainléger
2026-03-17 22:01:39 +01:00
parent 1f9a0996c0
commit 3bf8ccfb61
5 changed files with 102 additions and 54 deletions

View File

@@ -1,4 +1,5 @@
from odoo import _, api, fields, models
from odoo.exceptions import UserError
from odoo.tools.safe_eval import safe_eval
@@ -77,7 +78,10 @@ class CreateMaintenanceRequestsWizard(models.TransientModel):
)
if len(equipment_list) == 0:
raise UserError(
"No equipment is matching the domain. Maintenance request creation is not possible."
_(
"No equipment is matching the domain. "
"Maintenance request creation is not possible."
)
)
vals_list = []
@@ -104,7 +108,7 @@ class CreateMaintenanceRequestsWizard(models.TransientModel):
def _get_action(self, maintenance_requests):
"""
Provide the action to go to the tree view of the maintenance requests created.
Provide the action to go to the list view of the maintenance requests created.
"""
search_view_ref = self.env.ref(
"maintenance.hr_equipment_request_view_search", False
@@ -112,7 +116,7 @@ class CreateMaintenanceRequestsWizard(models.TransientModel):
form_view_ref = self.env.ref(
"maintenance.hr_equipment_request_view_form", False
)
tree_view_ref = self.env.ref(
list_view_ref = self.env.ref(
"maintenance.hr_equipment_request_view_tree", False
)
@@ -121,6 +125,6 @@ class CreateMaintenanceRequestsWizard(models.TransientModel):
"name": "Maintenance Requests",
"res_model": "maintenance.request",
"type": "ir.actions.act_window",
"views": [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")],
"views": [(list_view_ref.id, "list"), (form_view_ref.id, "form")],
"search_view_id": search_view_ref and [search_view_ref.id],
}