mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-19 06:52:09 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
# Copyright 2019 Solvos Consultoría Informática (<http://www.solvos.es>)
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class MaintenanceRequest(models.Model):
|
||||
_inherit = "maintenance.request"
|
||||
|
||||
project_id = fields.Many2one(comodel_name="project.project")
|
||||
task_id = fields.Many2one(comodel_name="project.task")
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
"""
|
||||
We ensure for appropiate project and task for new requests,
|
||||
specially the automatically generated ones
|
||||
"""
|
||||
newreqs = super().create(vals_list)
|
||||
for newreq in newreqs:
|
||||
if not newreq.project_id and newreq.equipment_id:
|
||||
newreq.project_id = newreq.equipment_id.project_id
|
||||
if not newreq.task_id and newreq.maintenance_type == "preventive":
|
||||
newreq.task_id = newreq.equipment_id.preventive_default_task_id
|
||||
|
||||
return newreqs
|
||||
|
||||
@api.onchange("equipment_id")
|
||||
def onchange_equipment_id(self):
|
||||
res = super().onchange_equipment_id()
|
||||
if self.equipment_id and self.equipment_id.project_id:
|
||||
self.project_id = self.equipment_id.project_id
|
||||
return res
|
||||
Loading…
Add table
Add a link
Reference in a new issue