Files
Odoo-Modules/fusion_plating/fusion_plating/migrations/19.0.12.4.1/post-migrate.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

98 lines
3.2 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
# Part of the Fusion Plating product family.
"""19.0.12.4.0 - Step-library polish + Policy B Contract Review backfill.
post_init_hook only fires on fresh install. Existing DBs upgrading
from pre-Policy-B versions need this migration to:
1. Add the missing 'Contract Review' library template (the
_seed_step_library_if_empty seeder skipped it because their
library was already populated when 19.0.12.3.0 landed).
2. Backfill default_kind on existing library entries that landed
without a kind because the original seeder used a brittle
case-sensitive lookup that missed common name variations
("E-Nickel Plating" vs "E-Nickel Plate", "DeRacking" vs
"De-Racking", "Ready for X" gating prefixes, etc.). The new
`fp_resolve_step_kind` helper is hyphen / case / -ing tolerant.
3. Add canonical missing entries (Soak Clean, Rinse, Etch, Acid Dip,
Drying, Inspection, Shipping, Water Break Test, Desmut, Zincate)
that ENP-ALUM-BASIC's seed didn't include - these are the names
a fresh estimator would expect to find when they open the library
from scratch. Without them, an empty recipe has no obvious starting
templates for cleaning / rinsing / standard inspection.
All three steps are idempotent - re-running on an already-fixed DB
is a no-op.
"""
import logging
from odoo.api import Environment
from odoo.addons.fusion_plating import fp_resolve_step_kind
_logger = logging.getLogger(__name__)
CANONICAL_MISSING = [
('Soak Clean', 'cleaning'),
('Electroclean', 'cleaning'),
('Rinse', 'rinse'),
('Etch', 'etch'),
('Desmut', 'etch'),
('Zincate', 'etch'),
('Acid Dip', 'etch'),
('HCl Activation', 'etch'),
('Water Break Test', 'wbf_test'),
('Drying', 'dry'),
('Inspection', 'inspect'),
('Final Inspection', 'final_inspect'),
('Shipping', 'ship'),
('Contract Review', 'contract_review'),
]
def migrate(cr, version):
env = Environment(cr, 1, {}) # SUPERUSER
Tpl = env['fp.step.template']
# ---- 1. Backfill default_kind on existing library entries -----------
blank_kind = Tpl.search([('default_kind', '=', False)])
fixed = 0
for tpl in blank_kind:
kind = fp_resolve_step_kind(tpl.name)
if kind:
tpl.default_kind = kind
tpl.action_seed_default_inputs()
fixed += 1
_logger.info(
'Fusion Plating 19.0.12.4.0: backfilled default_kind on %s/%s '
'library entries via fp_resolve_step_kind.',
fixed, len(blank_kind),
)
# ---- 2. Add canonical missing entries -------------------------------
existing_names_lower = {
(n.strip().lower()) for n in Tpl.search([]).mapped('name') if n
}
added = 0
for name, kind in CANONICAL_MISSING:
if name.lower() in existing_names_lower:
continue
tpl = Tpl.create({
'name': name,
'default_kind': kind,
})
tpl.action_seed_default_inputs()
added += 1
_logger.info(
'Fusion Plating 19.0.12.4.0: added %s canonical missing library '
'entries (Soak Clean, Rinse, Etch, etc.).', added,
)