[ADD] maintenance_create_requests_from_project_task: create add-on
This commit is contained in:
committed by
Stéphan Sainléger
parent
ff75a1b4cd
commit
1e7671c119
@@ -0,0 +1 @@
|
||||
from . import project_task
|
@@ -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
|
Reference in New Issue
Block a user