folder rename
This commit is contained in:
116
fusion_plating/fusion_plating_cgp/models/fp_cgp_registration.py
Normal file
116
fusion_plating/fusion_plating_cgp/models/fp_cgp_registration.py
Normal file
@@ -0,0 +1,116 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
# Part of the Fusion Plating product family.
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class FpCgpRegistration(models.Model):
|
||||
"""Canadian Controlled Goods Program registration.
|
||||
|
||||
Every Canadian entity that examines, possesses, or transfers
|
||||
controlled goods must be registered with Public Services and
|
||||
Procurement Canada (PSPC) under the Defence Production Act.
|
||||
Registration is valid for five years and must be renewed before
|
||||
it lapses. A single registration is usually held per legal entity,
|
||||
so this record lives on ``res.company``.
|
||||
"""
|
||||
_name = 'fusion.plating.cgp.registration'
|
||||
_description = 'Fusion Plating — CGP Registration'
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
_order = 'registration_date desc, id desc'
|
||||
|
||||
name = fields.Char(
|
||||
string='Reference',
|
||||
required=True,
|
||||
tracking=True,
|
||||
help='Label for this registration, e.g. "Acme Plating — CGP Reg."',
|
||||
)
|
||||
company_id = fields.Many2one(
|
||||
'res.company',
|
||||
string='Company',
|
||||
required=True,
|
||||
default=lambda self: self.env.company,
|
||||
tracking=True,
|
||||
)
|
||||
registration_number = fields.Char(
|
||||
string='PSPC Registration Number',
|
||||
tracking=True,
|
||||
help='Registration number assigned by PSPC when the entity '
|
||||
'is admitted to the Controlled Goods Program.',
|
||||
)
|
||||
registration_date = fields.Date(
|
||||
string='Registration Date',
|
||||
tracking=True,
|
||||
)
|
||||
expiry_date = fields.Date(
|
||||
string='Expiry Date',
|
||||
tracking=True,
|
||||
help='CGP registrations are typically valid for five years.',
|
||||
)
|
||||
state = fields.Selection(
|
||||
[
|
||||
('pending', 'Pending'),
|
||||
('registered', 'Registered'),
|
||||
('suspended', 'Suspended'),
|
||||
('expired', 'Expired'),
|
||||
('revoked', 'Revoked'),
|
||||
],
|
||||
string='Status',
|
||||
default='pending',
|
||||
required=True,
|
||||
tracking=True,
|
||||
)
|
||||
designated_official_id = fields.Many2one(
|
||||
'hr.employee',
|
||||
string='Designated Official',
|
||||
tracking=True,
|
||||
help='Top-level person legally accountable for CGP compliance '
|
||||
'at this entity. Must have an active PSA on file.',
|
||||
)
|
||||
physical_address = fields.Char(
|
||||
string='Registered Address',
|
||||
tracking=True,
|
||||
help='Physical address on record with PSPC.',
|
||||
)
|
||||
security_plan_doc_id = fields.Many2one(
|
||||
'fusion.plating.doc.control',
|
||||
string='Security Plan',
|
||||
help='Link to the controlled document holding the current '
|
||||
'CGP Security Plan for this registration.',
|
||||
)
|
||||
last_compliance_review = fields.Date(
|
||||
string='Last Compliance Review',
|
||||
tracking=True,
|
||||
)
|
||||
next_compliance_review = fields.Date(
|
||||
string='Next Compliance Review',
|
||||
tracking=True,
|
||||
)
|
||||
notes = fields.Html(string='Notes')
|
||||
active = fields.Boolean(default=True)
|
||||
|
||||
@api.onchange('registration_date')
|
||||
def _onchange_registration_date(self):
|
||||
"""Default expiry to five years after registration."""
|
||||
for rec in self:
|
||||
if rec.registration_date and not rec.expiry_date:
|
||||
rec.expiry_date = rec.registration_date + relativedelta(years=5)
|
||||
|
||||
def action_mark_registered(self):
|
||||
self.write({'state': 'registered'})
|
||||
|
||||
def action_suspend(self):
|
||||
self.write({'state': 'suspended'})
|
||||
|
||||
def action_expire(self):
|
||||
self.write({'state': 'expired'})
|
||||
|
||||
def action_revoke(self):
|
||||
self.write({'state': 'revoked'})
|
||||
|
||||
def action_reset_to_pending(self):
|
||||
self.write({'state': 'pending'})
|
||||
Reference in New Issue
Block a user