feat(fusion_accounting_reports): migration wizard bootstrap step verifies report definitions

Inherits fusion.migration.wizard from fusion_accounting_migration and
appends a _reports_bootstrap_step that confirms the 4 CORE report
definitions (pnl, balance_sheet, trial_balance, general_ledger) exist
after migration. Returns a structured result with expected, present, and
missing report types.

Hooked into action_run_migration via super(); failures are logged
(warning) but never raised, so the migration chain remains tolerant of
ordering between sub-modules.

Adds fusion_accounting_migration to manifest depends.

Tests: 1 new (test_migration_round_trip.py). Net 114 -> 115.
Made-with: Cursor
This commit is contained in:
gsinghpal
2026-04-19 16:18:39 -04:00
parent 8de4beb46a
commit e17e7f9e4c
5 changed files with 54 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
{
'name': 'Fusion Accounting Reports',
'version': '19.0.1.0.32',
'version': '19.0.1.0.33',
'category': 'Accounting/Accounting',
'summary': 'AI-augmented financial reports (P&L, balance sheet, trial balance, GL).',
'description': """
@@ -27,6 +27,7 @@ menu hides; the engine and AI tools remain available for the chat.
'depends': [
'fusion_accounting_core',
'fusion_accounting_ai',
'fusion_accounting_migration',
'account',
],
'data': [

View File

@@ -4,3 +4,4 @@ from . import fusion_report_commentary
from . import fusion_report_anomaly
from . import fusion_account_balance_mv
from . import fusion_reports_cron
from . import fusion_migration_wizard

View File

@@ -0,0 +1,35 @@
"""Reports-specific migration step.
Ensures the 4 CORE report definitions are present after migration."""
import logging
from odoo import models
_logger = logging.getLogger(__name__)
class FusionMigrationWizard(models.TransientModel):
_inherit = "fusion.migration.wizard"
def _reports_bootstrap_step(self):
"""Verify all 4 CORE report definitions exist."""
Report = self.env['fusion.report'].sudo()
expected = ['pnl', 'balance_sheet', 'trial_balance', 'general_ledger']
present = Report.search([('report_type', 'in', expected)]).mapped('report_type')
missing = set(expected) - set(present)
return {
'step': 'reports_bootstrap',
'expected_reports': expected,
'present_reports': list(present),
'missing_reports': list(missing),
}
def action_run_migration(self):
"""Override to add reports-bootstrap step at the end of the chain."""
result = super().action_run_migration() if hasattr(super(), 'action_run_migration') else None
try:
self._reports_bootstrap_step()
except Exception as e:
_logger.warning("reports_bootstrap_step failed: %s", e)
return result

View File

@@ -21,3 +21,4 @@ from . import test_cron
from . import test_pdf_export
from . import test_xlsx_export
from . import test_period_picker
from . import test_migration_round_trip

View File

@@ -0,0 +1,15 @@
"""Tests for the reports-bootstrap migration step."""
from odoo.tests.common import TransactionCase, tagged
@tagged('post_install', '-at_install')
class TestMigrationRoundTrip(TransactionCase):
def test_bootstrap_finds_all_4_reports(self):
wizard = self.env['fusion.migration.wizard'].create({})
result = wizard._reports_bootstrap_step()
self.assertEqual(result['step'], 'reports_bootstrap')
self.assertEqual(set(result['present_reports']),
{'pnl', 'balance_sheet', 'trial_balance', 'general_ledger'})
self.assertEqual(result['missing_reports'], [])