"""Pre-migration: convert legacy act_window report actions to client actions. In 19.0.1.1.1 we shipped 11 ``ir.actions.act_window`` records with ``view_mode='fusion_reports'``. Odoo's act_window resolver requires a matching ``ir.ui.view`` record per view_mode, so clicking those menus raised "View types not defined fusion_reports". 19.0.1.1.2 reissues the same xml_ids as ``ir.actions.client`` records with ``tag='fusion_reports'``. Odoo refuses to update a record across models, so this pre-migration drops the legacy records before the new data file loads. Idempotent: safe to re-run. """ import logging _logger = logging.getLogger(__name__) LEGACY_XIDS = ( 'action_fusion_report_pnl', 'action_fusion_report_balance_sheet', 'action_fusion_report_trial_balance', 'action_fusion_report_general_ledger', 'action_fusion_report_cash_flow', 'action_fusion_report_executive_summary', 'action_fusion_report_annual_statements', 'action_fusion_report_tax_summary', 'action_fusion_report_aged_receivable', 'action_fusion_report_aged_payable', 'action_fusion_report_partner_ledger', ) 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_reports' 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_reports.%s", name) if deleted: _logger.info( "fusion_accounting_reports pre-migration: dropped %d legacy " "act_window records to make way for ir.actions.client variants.", deleted, )