Files
Odoo-Modules/fusion_plating/fusion_plating_nuclear/models/fp_nuclear_itp.py
2026-04-16 20:53:53 -04:00

127 lines
3.6 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
# Part of the Fusion Plating product family.
from odoo import api, fields, models
class FpNuclearItp(models.Model):
"""Inspection and Test Plan (ITP).
For nuclear work, every critical part typically has an approved
Inspection and Test Plan that lists:
* Hold points (customer has to be present before work continues)
* Witness points (customer may be present)
* Review points (customer reviews records after the fact)
* Test methods and acceptance criteria
The ITP is usually prepared by the supplier, reviewed by the
customer, and formally approved before work can start. Once
approved, any deviation needs a change record.
"""
_name = 'fusion.plating.nuclear.itp'
_description = 'Fusion Plating — Nuclear Inspection and Test Plan'
_inherit = ['mail.thread', 'mail.activity.mixin']
_order = 'name desc'
name = fields.Char(
string='Reference',
required=True,
copy=False,
readonly=True,
default=lambda self: self._default_name(),
tracking=True,
)
customer_id = fields.Many2one(
'res.partner',
string='Customer',
required=True,
tracking=True,
)
part_number = fields.Char(
string='Part Number',
tracking=True,
)
drawing_ref = fields.Char(
string='Drawing Ref',
tracking=True,
)
n299_level_id = fields.Many2one(
'fusion.plating.n299.level',
string='CSA N299 Level',
tracking=True,
)
hold_points = fields.Html(
string='Hold / Witness / Review Points',
help='Document the hold, witness and review points the customer has '
'specified for this part.',
)
test_methods = fields.Html(
string='Test Methods',
)
acceptance_criteria = fields.Html(
string='Acceptance Criteria',
)
document_ids = fields.Many2many(
'ir.attachment',
'fp_nuclear_itp_attachment_rel',
'itp_id',
'attachment_id',
string='Attached Documents',
)
state = fields.Selection(
[
('draft', 'Draft'),
('customer_review', 'Customer Review'),
('approved', 'Approved'),
('in_use', 'In Use'),
('superseded', 'Superseded'),
],
string='Status',
default='draft',
required=True,
tracking=True,
)
customer_approval_date = fields.Date(
string='Customer Approval',
tracking=True,
)
company_id = fields.Many2one(
'res.company',
string='Company',
default=lambda self: self.env.company,
)
active = fields.Boolean(default=True)
@api.model
def _default_name(self):
seq = self.env['ir.sequence'].next_by_code('fusion.plating.nuclear.itp')
return seq or '/'
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if not vals.get('name') or vals.get('name') == '/':
vals['name'] = self._default_name()
return super().create(vals_list)
def action_submit_for_review(self):
self.write({'state': 'customer_review'})
def action_approve(self):
self.write({
'state': 'approved',
'customer_approval_date': fields.Date.context_today(self),
})
def action_put_in_use(self):
self.write({'state': 'in_use'})
def action_supersede(self):
self.write({'state': 'superseded'})
def action_reset_to_draft(self):
self.write({'state': 'draft'})