changes
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2026 Nexa Systems Inc.
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
"""19.0.33.2.0 — Drop fp.first.piece.gate model + all dependents.
|
||||
|
||||
The first-piece gate model was a skeleton: manual-create only, no
|
||||
enforcement gate, no FK to fp.job, 0 production rows on entech after
|
||||
months. Audit on 2026-05-25 concluded REMOVE.
|
||||
|
||||
Per Rule "Removing menus/records — Odoo does NOT auto-delete orphans":
|
||||
deleting <menuitem> / <record> tags from XML does NOT remove the
|
||||
corresponding DB rows. We have to explicitly drop them here.
|
||||
|
||||
Pre-migrate (vs post-migrate): runs BEFORE the new XML loads, so
|
||||
there's no window where the loader tries to reference the deleted
|
||||
model/action/view records and fails. Also runs before model __init__,
|
||||
so the registry never sees the (now-removed) Python class try to
|
||||
match against an existing-but-renamed DB table.
|
||||
"""
|
||||
import logging
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
_logger.info("Dropping fp.first.piece.gate model + all dependents")
|
||||
|
||||
# ---- 1. Drop the table (CASCADE wipes any inbound FKs we missed) ----
|
||||
cr.execute("""
|
||||
DROP TABLE IF EXISTS fusion_plating_first_piece_gate CASCADE
|
||||
""")
|
||||
|
||||
# ---- 2. ir.model row (cascades to ir.model.fields, ir.model.access,
|
||||
# and ir.model.constraint via Odoo's own FK rules) -----------
|
||||
cr.execute("""
|
||||
DELETE FROM ir_model
|
||||
WHERE model = 'fusion.plating.first.piece.gate'
|
||||
""")
|
||||
|
||||
# ---- 3. Orphan ir.ui.menu — the menuitem was removed from
|
||||
# fp_menu.xml; without explicit delete it'd linger ----------
|
||||
cr.execute("""
|
||||
DELETE FROM ir_ui_menu
|
||||
WHERE id IN (
|
||||
SELECT res_id FROM ir_model_data
|
||||
WHERE module = 'fusion_plating_shopfloor'
|
||||
AND model = 'ir.ui.menu'
|
||||
AND name = 'menu_fp_shopfloor_first_piece'
|
||||
)
|
||||
""")
|
||||
|
||||
# ---- 4. Orphan ir.actions.act_window ------------------------------
|
||||
cr.execute("""
|
||||
DELETE FROM ir_act_window
|
||||
WHERE id IN (
|
||||
SELECT res_id FROM ir_model_data
|
||||
WHERE module = 'fusion_plating_shopfloor'
|
||||
AND model = 'ir.actions.act_window'
|
||||
AND name = 'action_fp_first_piece_gate'
|
||||
)
|
||||
""")
|
||||
|
||||
# ---- 5. Drop the ir.sequence row + its companion postgres
|
||||
# sequence (Odoo creates a real PG seq named "fusion_plating_first_piece_gate") ----
|
||||
cr.execute("""
|
||||
DELETE FROM ir_sequence
|
||||
WHERE code = 'fusion.plating.first.piece.gate'
|
||||
""")
|
||||
cr.execute("""
|
||||
DROP SEQUENCE IF EXISTS fusion_plating_first_piece_gate
|
||||
""")
|
||||
|
||||
# ---- 6. Drop ALL remaining ir.model.data rows tagged for the
|
||||
# retired model so noupdate=1 demo seeds, view xmlids, etc.
|
||||
# don't ghost-haunt future upgrades ------------------------
|
||||
cr.execute("""
|
||||
DELETE FROM ir_model_data
|
||||
WHERE module = 'fusion_plating_shopfloor'
|
||||
AND ( name = 'menu_fp_shopfloor_first_piece'
|
||||
OR name = 'action_fp_first_piece_gate'
|
||||
OR name = 'seq_fp_first_piece_gate'
|
||||
OR name LIKE 'view_fp_first_piece%'
|
||||
OR name LIKE 'demo_fpg_%')
|
||||
""")
|
||||
|
||||
_logger.info(
|
||||
"fp.first.piece.gate removal complete: table dropped, ir.model "
|
||||
"row gone, menu/action/sequence/views/demo xmlids purged."
|
||||
)
|
||||
Reference in New Issue
Block a user