From 89267a9f41fe0e2e3d6110049166397911bee9c8 Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Wed, 27 May 2026 01:56:36 -0400 Subject: [PATCH] feat(certificates): partner toggles for Nadcap / MTR / Customer-Specific Adds three Boolean fields (x_fc_send_nadcap_cert, x_fc_send_mill_test, x_fc_send_customer_specific) to res.partner, default False. Wires aerospace/defence customers into the existing cert resolver so the three orphan fp.certificate.certificate_type values become reachable. Post-migrate idempotently backfills NULL -> FALSE on existing rows. Sub: docs/superpowers/specs/2026-05-27-recipe-cert-toggles-design.md Task: T1 of the implementation plan. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../__manifest__.py | 2 +- .../migrations/19.0.9.0.0/post-migrate.py | 38 +++++++++++++++++++ .../models/res_partner.py | 29 ++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 fusion_plating/fusion_plating_certificates/migrations/19.0.9.0.0/post-migrate.py diff --git a/fusion_plating/fusion_plating_certificates/__manifest__.py b/fusion_plating/fusion_plating_certificates/__manifest__.py index 9c0fdbcb..cc6c6c4a 100644 --- a/fusion_plating/fusion_plating_certificates/__manifest__.py +++ b/fusion_plating/fusion_plating_certificates/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'Fusion Plating — Certificates', - 'version': '19.0.8.0.0', + 'version': '19.0.9.0.0', 'category': 'Manufacturing/Plating', 'summary': 'Certificate registry for CoC, thickness reports, and quality documents.', 'description': """ diff --git a/fusion_plating/fusion_plating_certificates/migrations/19.0.9.0.0/post-migrate.py b/fusion_plating/fusion_plating_certificates/migrations/19.0.9.0.0/post-migrate.py new file mode 100644 index 00000000..575cd453 --- /dev/null +++ b/fusion_plating/fusion_plating_certificates/migrations/19.0.9.0.0/post-migrate.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Copyright 2026 Nexa Systems Inc. +# License OPL-1 +"""Post-migrate for 19.0.9.0.0 — Aerospace/Defence cert partner toggles. + +Backfills NULL -> FALSE on the three new Boolean columns added to +res.partner (x_fc_send_nadcap_cert, x_fc_send_mill_test, +x_fc_send_customer_specific). Idempotent; safe to re-run. Default +FALSE = opt-in (only aerospace/defence customers will see these +flipped on by the admin). + +Without this backfill, existing partner rows would read NULL on +the new columns and the resolver's `if p.x_fc_send_nadcap_cert` +check would short-circuit cleanly anyway — but explicit FALSE makes +SQL queries / reports cleaner and matches the existing partner-flag +storage convention. +""" +import logging + +_logger = logging.getLogger(__name__) + + +def migrate(cr, version): + if not version: + return + _logger.info( + '19.0.9.0.0 post-migrate: backfilling Aerospace/Defence cert ' + 'partner toggles to FALSE on existing res.partner rows' + ) + for col in ( + 'x_fc_send_nadcap_cert', + 'x_fc_send_mill_test', + 'x_fc_send_customer_specific', + ): + cr.execute( + "UPDATE res_partner SET %s = FALSE WHERE %s IS NULL" % (col, col) + ) + _logger.info(' %s: %d rows updated', col, cr.rowcount) diff --git a/fusion_plating/fusion_plating_certificates/models/res_partner.py b/fusion_plating/fusion_plating_certificates/models/res_partner.py index c72e446d..5bdbd0a4 100644 --- a/fusion_plating/fusion_plating_certificates/models/res_partner.py +++ b/fusion_plating/fusion_plating_certificates/models/res_partner.py @@ -49,6 +49,35 @@ class ResPartner(models.Model): 'for commercial customers.', ) + # Aerospace / Defence cert toggles (2026-05-27 — sub + # docs/superpowers/specs/2026-05-27-recipe-cert-toggles-design.md). + # Default False — opt-in for aerospace/defence customers only. + # Resolver _resolve_required_cert_types reads these alongside the + # existing x_fc_send_coc / x_fc_send_thickness_report. The three + # cert types (nadcap_cert / mill_test / customer_specific) are + # manual-attach: operator uploads the PDF, no QWeb auto-render. + x_fc_send_nadcap_cert = fields.Boolean( + string='Send Nadcap Certificate', + default=False, tracking=True, + help='Auto-spawn a Nadcap-type fp.certificate when a job for ' + 'this customer reaches awaiting_cert. Operator attaches ' + 'the supplier/PRI-issued PDF before clicking Issue — ' + 'there is no QWeb auto-render for this type.', + ) + x_fc_send_mill_test = fields.Boolean( + string='Send Mill Test Report (MTR)', + default=False, tracking=True, + help='Auto-spawn a Mill Test Report cert. Operator attaches ' + "the steel supplier's MTR PDF before issuing.", + ) + x_fc_send_customer_specific = fields.Boolean( + string='Send Customer-Specific Cert', + default=False, tracking=True, + help='Auto-spawn a customer-specific cert. Operator fills the ' + 'customer-supplied template PDF and attaches before ' + 'issuing.', + ) + # ---- Sub 6 — Per-contact communication routing ----------------------- # These five flags live on CHILD contacts under a company partner. # When every contact under a company leaves them blank, the resolver