diff --git a/fusion_accounting_reports/__manifest__.py b/fusion_accounting_reports/__manifest__.py index 013e8100..fa3def06 100644 --- a/fusion_accounting_reports/__manifest__.py +++ b/fusion_accounting_reports/__manifest__.py @@ -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': [ diff --git a/fusion_accounting_reports/models/__init__.py b/fusion_accounting_reports/models/__init__.py index 9beab560..7b5f53e1 100644 --- a/fusion_accounting_reports/models/__init__.py +++ b/fusion_accounting_reports/models/__init__.py @@ -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 diff --git a/fusion_accounting_reports/models/fusion_migration_wizard.py b/fusion_accounting_reports/models/fusion_migration_wizard.py new file mode 100644 index 00000000..7f409c1a --- /dev/null +++ b/fusion_accounting_reports/models/fusion_migration_wizard.py @@ -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 diff --git a/fusion_accounting_reports/tests/__init__.py b/fusion_accounting_reports/tests/__init__.py index ec92123c..adaa30d4 100644 --- a/fusion_accounting_reports/tests/__init__.py +++ b/fusion_accounting_reports/tests/__init__.py @@ -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 diff --git a/fusion_accounting_reports/tests/test_migration_round_trip.py b/fusion_accounting_reports/tests/test_migration_round_trip.py new file mode 100644 index 00000000..a0931ec3 --- /dev/null +++ b/fusion_accounting_reports/tests/test_migration_round_trip.py @@ -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'], [])