# -*- 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 FpCounterfeitPrevention(models.Model): """Counterfeit parts prevention incident log. Records an incident where a suspected or confirmed counterfeit / fraudulent part, material, or raw stock was detected in the supply chain. Required by AS9100 §8.1.4 Counterfeit Parts Prevention. """ _name = 'fusion.plating.counterfeit.prevention' _description = 'Fusion Plating — Counterfeit Parts Prevention Log' _inherit = ['mail.thread', 'mail.activity.mixin'] _order = 'incident_date desc, id desc' name = fields.Char( string='Reference', required=True, copy=False, readonly=True, default=lambda self: self._default_name(), tracking=True, ) incident_date = fields.Date( string='Incident Date', default=lambda self: fields.Date.context_today(self), tracking=True, ) supplier_id = fields.Many2one( 'res.partner', string='Supplier', tracking=True, ) part_number = fields.Char( string='Part Number', tracking=True, ) lot_serial = fields.Char( string='Lot / Serial', tracking=True, ) detection_method = fields.Char( string='Detection Method', help='How the counterfeit item was detected (receiving inspection, ' 'lab test, certificate discrepancy, etc.).', ) disposition = fields.Selection( [ ('returned', 'Returned to Supplier'), ('destroyed', 'Destroyed / Quarantined'), ('investigation', 'Under Investigation'), ], string='Disposition', default='investigation', tracking=True, ) gidep_reported = fields.Boolean( string='GIDEP Reported', tracking=True, help='Reported to the Government Industry Data Exchange Program.', ) notes = fields.Html( string='Notes', ) 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.counterfeit.prevention') 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)