cleanup_demo_data.py: deletes ALL fp.job, fp.job.step, timelogs, mrp.production, mrp.workorder, and dependent records (deliveries, certs, holds, portal jobs, racking inspections, uninvoiced SOs). Resets the fp.job sequence. Preserves masters. Force-cancels MOs/SOs via SQL UPDATE before unlink to bypass Odoo's _unlink_except_done and _unlink_except_draft_or_cancel guards. seed_demo_data.py: creates 31 fp.job rows distributed across all 6 states (draft=5, confirmed=6, in_progress=8, on_hold=3, done=6, cancelled=3). In_progress jobs have mixed step states with real timelogs to simulate a live shop floor. Falls back to direct fp.job creation when a customer's parts have no coating/recipe, ensuring customer variety even with sparse coating data. Both scripts: idempotent (safe to re-run), commit at end, walk dependents bottom-up to avoid FK violations. Used to reset entech demo data after the migration trial. Part of: native job model migration (spec 2026-04-25) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
- For every
mrp.productionrecord, creates a parallelfp.jobwith the same name and fields. Skips MOs that already have a fp.job mirror (fp.job.legacy_mrp_production_id == mo.id). - For every
mrp.workorderrecord, creates a parallelfp.job.step. Skips already-migrated WOs. - Migrates
mrp.workorder.time_idstofp.job.step.timelog. - Rebinds cross-references on dependent models (batches, holds, certs, deliveries, portal jobs, racking inspections).
- Audit log written to
/tmp/fp_jobs_migration.logand 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.