Replace em-dashes and en-dashes with hyphens across 789 shipped source files (py/xml/js/scss) so the delivered module reads as human-written; em-dashes had become a recognizable AI-generated tell. Internal .md dev notes are excluded. The WO-sticker mojibake strippers keep their dash search targets (now written — / –). No logic changes: comments and display strings only; validated with py_compile + lxml parse. Rewrite the 7 customer notification emails to be intake-neutral (ship-in / drop-off / pickup) and repair-aware, and fix the Shipped email documents line (packing slip vs bill of lading; certificate only when issued). Subjects use a hyphen separator. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
96 lines
4.3 KiB
Python
96 lines
4.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Copyright 2026 Nexa Systems Inc.
|
|
# License OPL-1 (Odoo Proprietary License v1.0)
|
|
from odoo import _, api, fields, models
|
|
from odoo.exceptions import UserError
|
|
|
|
|
|
class FpDischargeSample(models.Model):
|
|
_name = 'fusion.plating.discharge.sample'
|
|
_description = 'Fusion Plating - Discharge Sample'
|
|
_inherit = ['mail.thread', 'mail.activity.mixin']
|
|
_order = 'sample_date desc, id desc'
|
|
|
|
name = fields.Char(string='Reference', required=True, copy=False, default=lambda s: s._default_name(), tracking=True)
|
|
facility_id = fields.Many2one('fusion.plating.facility', string='Facility', required=True, ondelete='restrict', tracking=True)
|
|
company_id = fields.Many2one('res.company', related='facility_id.company_id', store=True, readonly=True)
|
|
sample_date = fields.Datetime(string='Sample Date', required=True, default=fields.Datetime.now, tracking=True)
|
|
sample_point = fields.Char(string='Sample Point')
|
|
collected_by_id = fields.Many2one('res.users', string='Collected By')
|
|
chain_of_custody_ref = fields.Char(string='Chain of Custody #')
|
|
lab_id = fields.Many2one('res.partner', string='Lab', domain=[('is_company', '=', True)])
|
|
lab_report_ref = fields.Char(string='Lab Report #')
|
|
received_date = fields.Date(string='Results Received')
|
|
state = fields.Selection(
|
|
[('draft', 'Draft'), ('sent_to_lab', 'Sent to Lab'), ('results_in', 'Results In'),
|
|
('escalated', 'Escalated'), ('closed', 'Closed')],
|
|
string='Status', default='draft', required=True, tracking=True,
|
|
)
|
|
line_ids = fields.One2many('fusion.plating.discharge.sample.line', 'sample_id', string='Parameters', copy=True)
|
|
worst_status = fields.Selection(
|
|
[('ok', 'OK'), ('warning', 'Warning'), ('out_of_spec', 'Out of Spec'), ('pending', 'Pending')],
|
|
string='Worst Result', compute='_compute_worst_status', store=True,
|
|
)
|
|
notes = fields.Html(string='Notes')
|
|
attachment_ids = fields.Many2many(
|
|
'ir.attachment', 'fp_discharge_sample_attachment_rel', 'sample_id', 'attachment_id', string='Attachments',
|
|
)
|
|
active = fields.Boolean(default=True)
|
|
|
|
@api.model
|
|
def _default_name(self):
|
|
seq = self.env['ir.sequence'].next_by_code('fusion.plating.discharge.sample')
|
|
return seq or '/'
|
|
|
|
@api.depends('line_ids', 'line_ids.status')
|
|
def _compute_worst_status(self):
|
|
order = ['out_of_spec', 'warning', 'pending', 'ok']
|
|
for rec in self:
|
|
statuses = [l.status for l in rec.line_ids if l.status]
|
|
worst = 'pending'
|
|
for s in order:
|
|
if s in statuses:
|
|
worst = s
|
|
break
|
|
rec.worst_status = worst if statuses else 'pending'
|
|
|
|
def action_send_to_lab(self):
|
|
self.write({'state': 'sent_to_lab'})
|
|
|
|
def action_results_in(self):
|
|
self.write({'state': 'results_in', 'received_date': fields.Date.context_today(self)})
|
|
|
|
def action_escalate(self):
|
|
self.write({'state': 'escalated'})
|
|
|
|
def action_close(self):
|
|
"""Block close until lab evidence is on file.
|
|
|
|
A closed discharge sample without a lab report ref + at least
|
|
one parameter reading + (when results are in) a lab cert
|
|
attachment fails any environmental audit. The whole point
|
|
of the record is to document the test was performed and what
|
|
the lab said.
|
|
"""
|
|
for rec in self:
|
|
missing = []
|
|
if not rec.lab_report_ref:
|
|
missing.append(_('Lab Report #'))
|
|
if not rec.received_date:
|
|
missing.append(_('Results Received Date'))
|
|
if not rec.line_ids:
|
|
missing.append(_('At least one parameter reading'))
|
|
if not rec.attachment_ids:
|
|
missing.append(_('Lab certificate / report attachment'))
|
|
if missing:
|
|
raise UserError(_(
|
|
'Cannot close discharge sample "%(name)s" - these '
|
|
'fields must be filled in first:\n • %(fields)s\n\n'
|
|
'Without lab evidence on file the record fails any '
|
|
'environmental compliance audit.'
|
|
) % {
|
|
'name': rec.name or rec.display_name,
|
|
'fields': '\n • '.join(missing),
|
|
})
|
|
self.write({'state': 'closed'})
|