Files
Odoo-Modules/fusion_plating/fusion_plating_certificates/models/fp_delivery.py
gsinghpal 8c76a16366 chore(plating): de-dash shipped code + intake-neutral customer emails
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>
2026-06-05 00:16:19 -04:00

60 lines
2.5 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
"""Cert-aware extension of fusion.plating.delivery.
Hard-blocks action_mark_delivered when the linked job still has any
draft certificate (CoC or Thickness Report). AS9100 / Nadcap
compliance: parts can't ship without paperwork.
Manager bypass: pass context key `fp_skip_cert_gate=True` (matches
the existing bypass convention on fp.job.button_mark_done).
"""
from odoo import _, models
from odoo.exceptions import UserError
class FusionPlatingDelivery(models.Model):
_inherit = 'fusion.plating.delivery'
def action_mark_delivered(self):
if not self.env.context.get('fp_skip_cert_gate'):
Cert = self.env.get('fp.certificate')
Job = self.env.get('fp.job')
if Cert is not None and Job is not None:
for delivery in self:
if not delivery.job_ref:
continue
job = Job.search(
[('name', '=', delivery.job_ref)], limit=1,
)
if not job:
continue
dom = [('state', '=', 'draft')]
if 'x_fc_job_id' in Cert._fields:
dom.append(('x_fc_job_id', '=', job.id))
elif (job.sale_order_id
and 'sale_order_id' in Cert._fields):
dom.append((
'sale_order_id', '=', job.sale_order_id.id,
))
else:
continue
draft_certs = Cert.search(dom)
if draft_certs:
raise UserError(_(
'Cannot mark delivery %(d)s shipped - job '
'%(j)s still has %(n)d draft '
'certificate(s) (%(types)s). Issue them '
'first, or pass fp_skip_cert_gate=True '
'context key to bypass.'
) % {
'd': delivery.name or delivery.id,
'j': job.name,
'n': len(draft_certs),
'types': ', '.join(sorted(set(
draft_certs.mapped('certificate_type')
))),
})
return super().action_mark_delivered()