Files
Odoo-Modules/fusion_plating/fusion_plating_receiving/migrations/19.0.3.10.0/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

49 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
"""Name-match existing fp_receiving.carrier_name → x_fc_carrier_id.
Phase A of the shipping integration replaces the free-text carrier
field with a Many2one to delivery.carrier. Existing records (16 on
entech at write time) have free-text values like "FedEx", "Purolator"
in carrier_name. This migration walks them and populates the new M2O
when a unique case-insensitive name match exists.
delivery.carrier.name is jsonb (translatable) in Odoo 19 - match
strips to the en_US translation. Ambiguous values stay as text in
carrier_name for the operator to pick manually.
"""
import logging
_logger = logging.getLogger(__name__)
def migrate(cr, version):
# Skip if the field doesn't exist yet (defensive - the column is
# added by the registry update that runs before post-migrate).
cr.execute("""
SELECT 1
FROM information_schema.columns
WHERE table_name = 'fp_receiving'
AND column_name = 'x_fc_carrier_id'
""")
if not cr.fetchone():
_logger.warning('x_fc_carrier_id column not present - skip.')
return
cr.execute("""
UPDATE fp_receiving r
SET x_fc_carrier_id = dc.id
FROM delivery_carrier dc
WHERE r.carrier_name IS NOT NULL
AND r.carrier_name <> ''
AND r.x_fc_carrier_id IS NULL
AND LOWER(TRIM(r.carrier_name)) =
LOWER(TRIM((dc.name->>'en_US')))
""")
matched = cr.rowcount
_logger.info(
'Receiving carrier migration: matched %d record(s) by name.',
matched,
)