Files
Odoo-Modules/fusion_plating/fusion_plating_jobs/scripts
gsinghpal 47a54eac8f feat(jobs): cutover - bridge_mrp gate, menu nesting, migration robustness
Three changes to support live cutover on entech (2026-04-25):

1. Bridge_mrp gate: sale.order.action_confirm in
   fusion_plating_bridge_mrp now skips _fp_auto_create_mo when the
   x_fc_use_native_jobs config flag is True. Without this, every SO
   confirm would create both an mrp.production AND an fp.job
   (duplicate work). The gate is the only modification to bridge_mrp
   during the migration — the rest stays untouched.

2. Menu nesting: Plating Jobs (Native) now lives INSIDE the existing
   Plating app (parent=menu_fp_root) instead of as a separate
   top-level app. Two parallel 'Plating' apps was confusing UX. Work
   Centres (Native) goes under the existing Configuration sub-menu.
   '(Native)' suffix is temporary — drops at full legacy removal.

3. Migration script robustness: per-MO savepoints (so one bad MO
   doesn't abort the whole transaction with cascading 'transaction
   aborted' errors) + extended partner resolver fallback chain
   (warehouse partner → company partner) for orphan demo MOs without
   SO link or x_fc_customer_id. Verified: 43 MOs + 297 WOs migrated
   on entech with 0 errors after these fixes.

Part of: native job model migration (spec 2026-04-25)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 04:05:02 -04:00
..

Native job migration scripts

migrate_to_fp_jobs.py

Copies live mrp.production / mrp.workorder records into the native fp.job / fp.job.step model. Idempotent — safe to run multiple times.

Usage

Run from the host (e.g. entech) using odoo shell:

ssh pve-worker5 "pct exec 111 -- bash -c 'su - odoo -s /bin/bash -c \"/usr/bin/odoo shell -c /etc/odoo/odoo.conf -d admin\" < /mnt/extra-addons/custom/fusion_plating_jobs/scripts/migrate_to_fp_jobs.py'"

Or interactively from odoo shell (Python exec builtin, not a shell call):

exec(open('/mnt/extra-addons/custom/fusion_plating_jobs/scripts/migrate_to_fp_jobs.py').read())

What it does

  1. For every mrp.production record, creates a parallel fp.job with the same name and fields. Skips MOs that already have a fp.job mirror (fp.job.legacy_mrp_production_id == mo.id).
  2. For every mrp.workorder record, creates a parallel fp.job.step. Skips already-migrated WOs.
  3. Migrates mrp.workorder.time_ids to fp.job.step.timelog.
  4. Rebinds cross-references on dependent models (batches, holds, certs, deliveries, portal jobs, racking inspections).
  5. Audit log written to /tmp/fp_jobs_migration.log and to a chatter post on each migrated job.

Safety

  • Idempotent. Re-running skips already-migrated records.
  • Read-only on legacy MO/WO records. Original data untouched.
  • Cross-reference rebinds add new x_fc_job_id / x_fc_step_id values without removing legacy production_id / workorder_id values. Both stay populated for the 2-week shadow period.
  • Wrap in a transaction (default for odoo shell); if anything fails, rollback.

Pre-migration audit

Run audit_pre_migration.py first to see what's about to happen. The script uses Python's exec builtin to load the file inside the running shell session — no shell exec involved.

Reports counts of MO/WO/dependent records and any data-quality concerns (MOs with no recipe, WOs with no work centre, etc).

Post-migration audit

Run audit_post_migration.py after to verify counts match.

Reports row counts on fp.job, fp.job.step, and confirms all dependent records have new x_fc_*_id values.