[ADD] maintenance_create_requests_from_project_task: create add-on #1

Merged
stephansainleger merged 2 commits from 16.0-create_maintenance_tasks_from_project_task into 16.0 2025-06-03 14:20:31 +00:00
13 changed files with 666 additions and 0 deletions
Showing only changes of commit 1fa2ddf961 - Show all commits

View File

@@ -0,0 +1,2 @@
*.*~
*pyc

View File

@@ -0,0 +1,48 @@
=============================================
maintenance_create_requests_from_project_task
=============================================
Allow the creation of multiple maintenance requests from a projet task.
When user click on the button "Create maintenance requests", a wizard appears.
The wizard allows the user to configure the requests and to select the maintenance equipments concerned.
At wizard validation, one or several maintenance requests are created, one for each equipement selected.
Installation
============
Use Odoo normal module installation procedure to install
``maintenance_create_requests_from_project_task``.
Known issues / Roadmap
======================
None yet.
Bug Tracker
===========
Bugs are tracked on `our issues website <https://github.com/elabore-coop/maintenance-tools/issues>`_. In case of
trouble, please check there if your issue has already been
reported. If you spotted it first, help us smashing it by providing a
detailed and welcomed feedback.
Credits
=======
Contributors
------------
* Stéphan Sainléger
Funders
-------
The development of this module has been financially supported by:
* Elabore (https://elabore.coop)
Maintainer
----------
This module is maintained by Elabore.

View File

@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
from . import models
from . import wizard

View File

@@ -0,0 +1,41 @@
# Copyright 2023 Stéphan Sainléger (Elabore)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "maintenance_create_requests_from_project_task",
"version": "16.0.1.0.0",
"author": "Elabore",
"website": "https://elabore.coop",
"maintainer": "Stéphan Sainléger",
"license": "AGPL-3",
"category": "Tools",
"summary": "Allow the creation of multiple maintenance requests from a projet task.",
# any module necessary for this one to work correctly
"depends": [
"base",
"maintenance",
"maintenance_project",
"project",
],
"qweb": [
# "static/src/xml/*.xml",
],
"external_dependencies": {
"python": [],
},
# always loaded
"data": [
"security/ir.model.access.csv",
"views/project_task.xml",
"wizard/create_maintenance_requests_wizard.xml",
],
# only loaded in demonstration mode
"demo": [],
"js": [],
"css": [],
"installable": True,
# Install this module automatically if all dependency have been previously
# and independently installed. Used for synergetic or glue modules.
"auto_install": False,
"application": False,
}

View File

@@ -0,0 +1,182 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * maintenance_create_requests_from_project_task
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-06-02 22:52+0000\n"
"PO-Revision-Date: 2025-06-03 00:58+0200\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_create_requests_from_project_task
#: model_terms:ir.ui.view,arch_db:maintenance_create_requests_from_project_task.create_maintenance_requests_wizard_view_form
msgid "Cancel"
msgstr "Annuler"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model,name:maintenance_create_requests_from_project_task.model_create_maintenance_requests_wizard
msgid "Configure the maintenance requests to create from the current task."
msgstr "Définir les données des demandes de maintenance à créer depuis la tâche actuelle."
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields.selection,name:maintenance_create_requests_from_project_task.selection__create_maintenance_requests_wizard__maintenance_type__corrective
msgid "Corrective"
msgstr "Corrective"
#. module: maintenance_create_requests_from_project_task
#: model_terms:ir.ui.view,arch_db:maintenance_create_requests_from_project_task.create_maintenance_requests_wizard_view_form
msgid "Create"
msgstr "Créer"
#. module: maintenance_create_requests_from_project_task
#: model:ir.actions.act_window,name:maintenance_create_requests_from_project_task.action_create_maintenance_requests_wizard
msgid "Create Maintenance Requests"
msgstr "Créer des demandes de maintenance"
#. module: maintenance_create_requests_from_project_task
#. odoo-python
#: code:addons/maintenance_create_requests_from_project_task/wizard/create_maintenance_requests_wizard.py:0
#: model:ir.actions.server,name:maintenance_create_requests_from_project_task.task_wizard_action_create_maintenance_requests
#: model_terms:ir.ui.view,arch_db:maintenance_create_requests_from_project_task.create_maintenance_requests_wizard_view_form
#, python-format
msgid "Create maintenance requests"
msgstr "Créer des demandes de maintenance"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__create_uid
msgid "Created by"
msgstr "Créé par"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__create_date
msgid "Created on"
msgstr "Créé le"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__description
msgid "Description"
msgstr "Description"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__display_name
msgid "Display Name"
msgstr "Nom affiché"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__duration
msgid "Duration"
msgstr "Durée"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,help:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__duration
msgid "Duration in hours."
msgstr "Durée en heures."
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__equipment_domain
msgid "Equipment Domain"
msgstr "Domaine des équipements"
#. module: maintenance_create_requests_from_project_task
#: model_terms:ir.ui.view,arch_db:maintenance_create_requests_from_project_task.create_maintenance_requests_wizard_view_form
msgid "Equipments targetted"
msgstr "Équipements ciblés"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields.selection,name:maintenance_create_requests_from_project_task.selection__create_maintenance_requests_wizard__priority__3
msgid "High"
msgstr "Élevé"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__id
msgid "ID"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard____last_update
msgid "Last Modified on"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__write_uid
msgid "Last Updated by"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__write_date
msgid "Last Updated on"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields.selection,name:maintenance_create_requests_from_project_task.selection__create_maintenance_requests_wizard__priority__1
msgid "Low"
msgstr "Bas"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_project_task__maintenance_request_count
msgid "Maintenance Request Count"
msgstr "Nombre de demandes de maintenance"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_project_task__maintenance_request_ids
#: model_terms:ir.ui.view,arch_db:maintenance_create_requests_from_project_task.view_task_form2_maintenance_inherited
msgid "Maintenance Requests"
msgstr "Demandes de maintenance"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__maintenance_type
msgid "Maintenance Type"
msgstr "Type de maintenance"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields.selection,name:maintenance_create_requests_from_project_task.selection__create_maintenance_requests_wizard__priority__2
msgid "Normal"
msgstr "Normal"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields.selection,name:maintenance_create_requests_from_project_task.selection__create_maintenance_requests_wizard__maintenance_type__preventive
msgid "Preventive"
msgstr "Préventive"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__priority
msgid "Priority"
msgstr "Priorité"
#. module: maintenance_create_requests_from_project_task
#: model_terms:ir.ui.view,arch_db:maintenance_create_requests_from_project_task.create_maintenance_requests_wizard_view_form
msgid "Requests data"
msgstr "Données"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__schedule_date
msgid "Scheduled Date"
msgstr "Date prévue"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model,name:maintenance_create_requests_from_project_task.model_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__task_id
msgid "Task"
msgstr "Tâche"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__user_id
msgid "Technician"
msgstr "Technicien"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__name
msgid "Title"
msgstr "Nom"
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields.selection,name:maintenance_create_requests_from_project_task.selection__create_maintenance_requests_wizard__priority__0
msgid "Very Low"
msgstr "Très bas"

View File

@@ -0,0 +1,182 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * maintenance_create_requests_from_project_task
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-06-02 22:52+0000\n"
"PO-Revision-Date: 2025-06-02 22:52+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_create_requests_from_project_task
#: model_terms:ir.ui.view,arch_db:maintenance_create_requests_from_project_task.create_maintenance_requests_wizard_view_form
msgid "Cancel"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model,name:maintenance_create_requests_from_project_task.model_create_maintenance_requests_wizard
msgid "Configure the maintenance requests to create from the current task."
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields.selection,name:maintenance_create_requests_from_project_task.selection__create_maintenance_requests_wizard__maintenance_type__corrective
msgid "Corrective"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model_terms:ir.ui.view,arch_db:maintenance_create_requests_from_project_task.create_maintenance_requests_wizard_view_form
msgid "Create"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.actions.act_window,name:maintenance_create_requests_from_project_task.action_create_maintenance_requests_wizard
msgid "Create Maintenance Requests"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#. odoo-python
#: code:addons/maintenance_create_requests_from_project_task/wizard/create_maintenance_requests_wizard.py:0
#: model:ir.actions.server,name:maintenance_create_requests_from_project_task.task_wizard_action_create_maintenance_requests
#: model_terms:ir.ui.view,arch_db:maintenance_create_requests_from_project_task.create_maintenance_requests_wizard_view_form
#, python-format
msgid "Create maintenance requests"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__create_uid
msgid "Created by"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__create_date
msgid "Created on"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__description
msgid "Description"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__display_name
msgid "Display Name"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__duration
msgid "Duration"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,help:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__duration
msgid "Duration in hours."
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__equipment_domain
msgid "Equipment Domain"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model_terms:ir.ui.view,arch_db:maintenance_create_requests_from_project_task.create_maintenance_requests_wizard_view_form
msgid "Equipments targetted"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields.selection,name:maintenance_create_requests_from_project_task.selection__create_maintenance_requests_wizard__priority__3
msgid "High"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__id
msgid "ID"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard____last_update
msgid "Last Modified on"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__write_uid
msgid "Last Updated by"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__write_date
msgid "Last Updated on"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields.selection,name:maintenance_create_requests_from_project_task.selection__create_maintenance_requests_wizard__priority__1
msgid "Low"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_project_task__maintenance_request_count
msgid "Maintenance Request Count"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_project_task__maintenance_request_ids
#: model_terms:ir.ui.view,arch_db:maintenance_create_requests_from_project_task.view_task_form2_maintenance_inherited
msgid "Maintenance Requests"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__maintenance_type
msgid "Maintenance Type"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields.selection,name:maintenance_create_requests_from_project_task.selection__create_maintenance_requests_wizard__priority__2
msgid "Normal"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields.selection,name:maintenance_create_requests_from_project_task.selection__create_maintenance_requests_wizard__maintenance_type__preventive
msgid "Preventive"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__priority
msgid "Priority"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model_terms:ir.ui.view,arch_db:maintenance_create_requests_from_project_task.create_maintenance_requests_wizard_view_form
msgid "Requests data"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__schedule_date
msgid "Scheduled Date"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model,name:maintenance_create_requests_from_project_task.model_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__task_id
msgid "Task"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__user_id
msgid "Technician"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields,field_description:maintenance_create_requests_from_project_task.field_create_maintenance_requests_wizard__name
msgid "Title"
msgstr ""
#. module: maintenance_create_requests_from_project_task
#: model:ir.model.fields.selection,name:maintenance_create_requests_from_project_task.selection__create_maintenance_requests_wizard__priority__0
msgid "Very Low"
msgstr ""

View File

@@ -0,0 +1 @@
from . import project_task

View File

@@ -0,0 +1,29 @@
from odoo import fields, models, api
class ProjectTask(models.Model):
_inherit = "project.task"
maintenance_request_ids = fields.One2many("maintenance.request", "task_id", string="Maintenance Requests")
maintenance_request_count = fields.Integer(
compute="_compute_maintenance_request_count"
)
@api.depends("maintenance_request_ids")
def _compute_maintenance_request_count(self):
for task in self:
task.maintenance_request_count = len(
task.maintenance_request_ids.filtered(lambda x: not x.stage_id.done)
)
def action_view_maintenance_request_ids(self):
"""
Access to the undone maintenance requests for this task
"""
self.ensure_one()
action = self.env["ir.actions.actions"]._for_xml_id(
"maintenance.hr_equipment_request_action"
)
action["domain"] = [("task_id", "=", self.id), ("stage_id.done", "=", False)]
action["context"] = {"default_task_id": self.id}
return action

View File

@@ -0,0 +1,2 @@
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_create_maintenance_requests_wizard,maintenance_create_requests_from_portal_tasks.create_maintenance_requests_wizard.access,model_create_maintenance_requests_wizard,base.group_user,1,1,1,0
1 id name model_id/id group_id/id perm_read perm_write perm_create perm_unlink
2 access_create_maintenance_requests_wizard maintenance_create_requests_from_portal_tasks.create_maintenance_requests_wizard.access model_create_maintenance_requests_wizard base.group_user 1 1 1 0

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_task_form2_maintenance_inherited" model="ir.ui.view">
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_form2" />
<field name="arch" type="xml">
<xpath expr="//field[@name='company_id']" position="after">
<field name="maintenance_request_count" invisible="1"/>
</xpath>
<xpath expr="//div[@name='button_box']" position="inside">
<button name="action_view_maintenance_request_ids" type="object" attrs="{'invisible': [('maintenance_request_count', '=', 0)]}" class="oe_stat_button" icon="fa-tasks" >
<div class="o_field_widget o_stat_info">
<span class="o_stat_value ">
<field name="maintenance_request_count" widget="statinfo" nolabel="1" />
Maintenance Requests
</span>
</div>
</button>
</xpath>
</field>
</record>
</odoo>

View File

@@ -0,0 +1 @@
from . import create_maintenance_requests_wizard

View File

@@ -0,0 +1,98 @@
from odoo import api, fields, models, _
from odoo.tools.safe_eval import safe_eval
class CreateMaintenanceRequestsWizard(models.TransientModel):
_name= "create.maintenance.requests.wizard"
_description= "Configure the maintenance requests to create from the current task."
@api.model
def _default_task_id(self):
return self.env["project.task"].browse(self._context.get("active_ids"))
name = fields.Char("Title", required=True)
user_id = fields.Many2one('res.users', string='Technician')
priority = fields.Selection([('0', 'Very Low'), ('1', 'Low'), ('2', 'Normal'), ('3', 'High')], string='Priority')
maintenance_type = fields.Selection([('corrective', 'Corrective'), ('preventive', 'Preventive')], string='Maintenance Type', default="corrective")
schedule_date = fields.Datetime('Scheduled Date')
duration = fields.Float(help="Duration in hours.")
description = fields.Html('Description')
equipment_domain = fields.Char("Equipment Domain")
task_id = fields.Many2one(
"project.task",
string="Task",
required=True,
default=_default_task_id,
)
@api.model
def action_open_wizard(self):
"""
Open the form view.
"""
return {
'name': _('Create maintenance requests'),
'type': 'ir.actions.act_window',
'res_model': 'create.maintenance.requests.wizard',
'view_type': 'form',
'view_mode': 'form',
'target': 'new',
}
def create_maintenance_requests(self):
"""
Create the maintenance requests with the data filled in the wizard form.
"""
vals_list = self._compute_vals_list()
maintenance_requests = self.env["maintenance.request"].sudo().create(vals_list)
return self._get_action(maintenance_requests)
def _compute_vals_list(self):
"""
Compute the list of data to use for all the maintenance requests creation
"""
equipment_list = self.env["maintenance.equipment"].search(safe_eval(self.equipment_domain))
if len(equipment_list) == 0:
raise UserError("No equipment is matching the domain. Maintenance request creation is not possible.")
vals_list = []
common_vals = {
"name": self.name,
"user_id": self.user_id.id,
"priority": self.priority,
"maintenance_type": self.maintenance_type,
"schedule_date": self.schedule_date,
"duration": self.duration,
"description": self.description,
"task_id": self.task_id.id,
"project_id": self.task_id.project_id.id
}
for equipment in equipment_list:
vals = common_vals.copy()
vals["equipment_id"] = equipment.id
vals_list.append(vals)
return vals_list
def _get_action(self, maintenance_requests):
"""
Provide the action to go to the tree view of the maintenance requests created.
"""
search_view_ref = self.env.ref('maintenance.hr_equipment_request_view_search', False)
form_view_ref = self.env.ref('maintenance.hr_equipment_request_view_form', False)
tree_view_ref = self.env.ref('maintenance.hr_equipment_request_view_tree', False)
return {
'domain': [('id', 'in', maintenance_requests.ids)],
'name': 'Maintenance Requests',
'res_model': 'maintenance.request',
'type': 'ir.actions.act_window',
'views': [(tree_view_ref.id, 'tree'), (form_view_ref.id, 'form')],
'search_view_id': search_view_ref and [search_view_ref.id],
}

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="create_maintenance_requests_wizard_view_form" model="ir.ui.view">
<field name="name">create.maintenance.requests.wizard.view.form</field>
<field name="model">create.maintenance.requests.wizard</field>
<field name="arch" type="xml">
<form string="Create maintenance requests">
<sheet>
<group name="name">
<field name="task_id" readonly="1" />
<field name="name" />
</group>
<group name="domain" string="Equipments targetted">
<field
name="equipment_domain"
widget="domain"
options='{"model": "maintenance.equipment"}'
/>
</group>
<group name="data" string="Requests data">
<field name="user_id" />
<field name="maintenance_type" />
<field name="priority" />
<field name="duration" />
<field name="schedule_date" />
<field name="description" />
</group>
</sheet>
<footer>
<button string="Create" name="create_maintenance_requests" type="object"
class="btn-primary" />
<button string="Cancel" class="btn-secondary" special="cancel" />
</footer>
</form>
</field>
</record>
<record
id="action_create_maintenance_requests_wizard" model="ir.actions.act_window">
<field name="name">Create Maintenance Requests</field>
<field name="res_model">create.maintenance.requests.wizard</field>
<field name="view_mode">form</field>
<field name="view_id" ref="create_maintenance_requests_wizard_view_form" />
<field name="target">new</field>
</record>
<record id="task_wizard_action_create_maintenance_requests" model="ir.actions.server">
<field name="name">Create maintenance requests</field>
<field name="model_id" ref="maintenance_create_requests_from_project_task.model_create_maintenance_requests_wizard"/>
<field name="binding_model_id" ref="project.model_project_task"/>
<field name="state">code</field>
<field name="code">action = model.action_open_wizard()</field>
</record>
</odoo>