Files
Odoo-Modules/fusion_plating/fusion_plating_configurator/migrations/19.0.9.0.0/post-migration.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

85 lines
3.0 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1
# Sub 2 - Part Data Model Overhaul. Runs on upgrade from < 19.0.9.0.0.
# Idempotent (NULL / empty guards). Safe to re-run.
import logging
_logger = logging.getLogger(__name__)
def migrate(cr, version):
if not version:
return # Fresh install - nothing to migrate
_logger.info("Sub 2: starting part-data-model migration to %s", version)
# Step 1: Backfill part_number from name where empty
cr.execute("""
UPDATE fp_part_catalog
SET part_number = name
WHERE part_number IS NULL OR part_number = ''
""")
_logger.info("Sub 2: backfilled part_number on %d records", cr.rowcount)
# Step 2: Backfill revision with 'A' where empty
cr.execute("""
UPDATE fp_part_catalog
SET revision = 'A'
WHERE revision IS NULL OR revision = ''
""")
_logger.info("Sub 2: backfilled revision on %d records", cr.rowcount)
# Step 3: Split fp_sale_description_template.description into two columns
# Copy existing description into BOTH internal_description and
# customer_facing_description. Estimators split them later.
cr.execute("""
UPDATE fp_sale_description_template
SET internal_description = description,
customer_facing_description = description
WHERE description IS NOT NULL
AND description <> ''
AND (internal_description IS NULL OR internal_description = '')
""")
_logger.info(
"Sub 2: duplicated description into new columns on %d template rows",
cr.rowcount,
)
# Step 4: Backfill x_fc_internal_description on sale.order.line
# Copy the existing `name` (Odoo's line description) into internal so
# historical lines satisfy the required-field check when it flips.
cr.execute("""
UPDATE sale_order_line
SET x_fc_internal_description = name
WHERE x_fc_internal_description IS NULL OR x_fc_internal_description = ''
""")
_logger.info(
"Sub 2: backfilled x_fc_internal_description on %d SO lines",
cr.rowcount,
)
# Step 5: Default certificate_requirement to 'inherit' on any rows
# where it's NULL (shouldn't happen given Odoo default=, but defensive).
cr.execute("""
UPDATE fp_part_catalog
SET certificate_requirement = 'inherit'
WHERE certificate_requirement IS NULL
""")
_logger.info(
"Sub 2: defaulted certificate_requirement to 'inherit' on %d parts",
cr.rowcount,
)
# Step 6: Drop legacy description column (all reads migrated to new fields).
# Runs after Steps 3 duplicated data into internal_description +
# customer_facing_description. Idempotent via IF EXISTS.
cr.execute("""
ALTER TABLE fp_sale_description_template
DROP COLUMN IF EXISTS description
""")
_logger.info("Sub 2: dropped legacy description column")
_logger.info("Sub 2: migration complete")