Implements the milestone-cascade design (Phase 1) and catches the fusion_plating_jobs / fusion_plating_certificates source up to entech. Milestone cascade (this PR's core): - fp.job: new computes all_steps_terminal, next_milestone_action, next_milestone_label; dispatcher action_advance_next_milestone with 3 helpers (_action_open_draft_certs, _action_open_draft_delivery, _action_mark_active_delivery_delivered); _resolve_required_cert_types resolver; _fp_create_certificates rewritten to honour part.certificate_requirement + partner flags + loop over resolved cert types - fp.job.workflow.state: new trigger_on_delivery_state Boolean; _fp_is_passed_for_job extended with delivery-state branch; Shipped state seed reroutes from default_kind=ship to the new trigger - View: hide Finish & Next when all_steps_terminal; add 4 mutually- exclusive milestone buttons (Mark Job Done / Issue Certs / Schedule Delivery / Mark Shipped) bound to one dispatcher - Cert gate (fusion_plating_certificates/models/fp_delivery.py): action_mark_delivered hard-blocks on draft certs; manager bypass via fp_skip_cert_gate=True context key - 24 unit tests in test_fp_job_milestone_cascade.py covering computes, resolver, dispatcher, cert gate - Spec: docs/superpowers/specs/2026-05-12-job-milestone-cascade-design.md - Plan: docs/superpowers/plans/2026-05-12-job-milestone-cascade.md Other entech changes caught up in this sync (from earlier session patches not previously committed): - fp.job version bump series 18.x → 19.0 - res_users_views.xml addition (signature widget in user prefs) - racking inspection smart button removal - various view/manifest touch-ups Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
60 lines
2.5 KiB
Python
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()
|