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) <noreply@anthropic.com>
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
# -*- 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)
|