Files
Odoo-Modules/fusion_accounting_l10n_ca/migrations/19.0.1.1.1/pre-migration.py
gsinghpal 8a841e7534 changes
2026-04-20 13:07:15 -04:00

49 lines
1.4 KiB
Python

"""Pre-migration: convert legacy act_window Canadian report actions.
Sibling of fusion_accounting_reports/migrations/19.0.1.1.2/pre-migration.py.
See that file for the full rationale.
"""
import logging
_logger = logging.getLogger(__name__)
LEGACY_XIDS = (
'action_fusion_report_ca_pnl',
'action_fusion_report_ca_bs',
)
def migrate(cr, version):
if not version:
return
deleted = 0
for name in LEGACY_XIDS:
cr.execute(
"""
SELECT id, model, res_id
FROM ir_model_data
WHERE module = 'fusion_accounting_l10n_ca' AND name = %s
""",
(name,),
)
row = cr.fetchone()
if not row:
continue
ir_md_id, model, res_id = row
if model != 'ir.actions.act_window':
continue
cr.execute("DELETE FROM ir_act_window WHERE id = %s", (res_id,))
cr.execute("DELETE FROM ir_actions WHERE id = %s", (res_id,))
cr.execute("DELETE FROM ir_model_data WHERE id = %s", (ir_md_id,))
deleted += 1
_logger.info("Dropped legacy act_window for fusion_accounting_l10n_ca.%s", name)
if deleted:
_logger.info(
"fusion_accounting_l10n_ca pre-migration: dropped %d legacy "
"act_window records to make way for ir.actions.client variants.",
deleted,
)