Files
Odoo-Modules/fusion_plating/fusion_plating_jobs/migrations/19.0.6.0.0/pre-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

90 lines
2.9 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1
#
# Phase 1 (Sub 11) - relocate ir.model.data XML IDs from
# fusion_plating_bridge_mrp to fusion_plating_jobs for the four
# models that moved: fp.work.role, fp.operator.proficiency,
# fp.qc.checklist.template (+line), fp.job.consumption.
#
# Pre-migration so Odoo's normal load pass sees the records under the
# new module owner, not as orphans pending deletion.
#
# Idempotent - `ON CONFLICT DO NOTHING` skips rows already migrated.
import logging
_logger = logging.getLogger(__name__)
def migrate(cr, version):
if not version:
return # Fresh install - nothing to migrate
moves = [
# (xmlid pattern, list of model identifiers to move)
('model_fp_job_consumption',),
# ACL records (csv:id values get prefixed with the owning module)
('access_fp_job_consumption_%',),
]
for (pat,) in moves:
cr.execute(
"""
UPDATE ir_model_data
SET module = 'fusion_plating_jobs'
WHERE module = 'fusion_plating_bridge_mrp'
AND name LIKE %s
AND NOT EXISTS (
SELECT 1 FROM ir_model_data d2
WHERE d2.module = 'fusion_plating_jobs'
AND d2.name = ir_model_data.name
)
""",
(pat,),
)
if cr.rowcount:
_logger.info(
"Sub 11: re-keyed %d ir.model.data rows matching %s -> fusion_plating_jobs",
cr.rowcount, pat,
)
# Views, actions, menus that the old module created
view_patterns = [
'view_fp_job_consumption_%',
'action_fp_job_consumption%',
'menu_fp_job_consumption%',
]
for pat in view_patterns:
cr.execute(
"""
UPDATE ir_model_data
SET module = 'fusion_plating_jobs'
WHERE module = 'fusion_plating_bridge_mrp'
AND name LIKE %s
AND NOT EXISTS (
SELECT 1 FROM ir_model_data d2
WHERE d2.module = 'fusion_plating_jobs'
AND d2.name = ir_model_data.name
)
""",
(pat,),
)
if cr.rowcount:
_logger.info(
"Sub 11: re-keyed %d row(s) for %s -> fusion_plating_jobs",
cr.rowcount, pat,
)
# Phase 1 swap: fp.job.consumption columns. Drop the legacy
# MRP-pointing columns (production_id, workorder_id) from the
# already-existing table - there are zero rows referencing MRP, and
# the new model declares job_id / step_id instead.
cr.execute(
"""
ALTER TABLE fp_job_consumption
DROP COLUMN IF EXISTS production_id,
DROP COLUMN IF EXISTS workorder_id
"""
)
_logger.info("Sub 11: dropped MRP columns on fp_job_consumption")