changes
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class FpMaintenancePlan(models.Model):
|
||||
"""Maintenance plan template.
|
||||
|
||||
Groups checklist nodes and links to an equipment category.
|
||||
Plans are selected when creating maintenance events.
|
||||
"""
|
||||
_name = 'fp.maintenance.plan'
|
||||
_description = 'Fusion Plating — Maintenance Plan'
|
||||
_inherit = ['mail.thread']
|
||||
_order = 'name'
|
||||
|
||||
name = fields.Char(
|
||||
string='Name',
|
||||
required=True,
|
||||
tracking=True,
|
||||
help='e.g. "Tank A-10 Nickel Nichem HP 1170 - Daily Titration"',
|
||||
)
|
||||
equipment_category_id = fields.Many2one(
|
||||
'maintenance.equipment.category',
|
||||
string='Equipment Type',
|
||||
ondelete='set null',
|
||||
tracking=True,
|
||||
)
|
||||
description = fields.Html(string='Description')
|
||||
default_assignee_id = fields.Many2one(
|
||||
'res.users',
|
||||
string='Default Assignee',
|
||||
)
|
||||
node_ids = fields.One2many(
|
||||
'fp.maintenance.node',
|
||||
'plan_id',
|
||||
string='Checklist Items',
|
||||
)
|
||||
node_count = fields.Integer(
|
||||
string='Items',
|
||||
compute='_compute_node_count',
|
||||
)
|
||||
active = fields.Boolean(default=True)
|
||||
company_id = fields.Many2one(
|
||||
'res.company',
|
||||
string='Company',
|
||||
default=lambda self: self.env.company,
|
||||
)
|
||||
|
||||
def _compute_node_count(self):
|
||||
for plan in self:
|
||||
plan.node_count = len(plan.node_ids)
|
||||
|
||||
def action_view_nodes(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': f'Items — {self.name}',
|
||||
'res_model': 'fp.maintenance.node',
|
||||
'view_mode': 'list,form',
|
||||
'domain': [('plan_id', '=', self.id)],
|
||||
'context': {'default_plan_id': self.id},
|
||||
}
|
||||
Reference in New Issue
Block a user