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:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
'name': 'Fusion Accounting Reports',
|
'name': 'Fusion Accounting Reports',
|
||||||
'version': '19.0.1.0.32',
|
'version': '19.0.1.0.33',
|
||||||
'category': 'Accounting/Accounting',
|
'category': 'Accounting/Accounting',
|
||||||
'summary': 'AI-augmented financial reports (P&L, balance sheet, trial balance, GL).',
|
'summary': 'AI-augmented financial reports (P&L, balance sheet, trial balance, GL).',
|
||||||
'description': """
|
'description': """
|
||||||
@@ -27,6 +27,7 @@ menu hides; the engine and AI tools remain available for the chat.
|
|||||||
'depends': [
|
'depends': [
|
||||||
'fusion_accounting_core',
|
'fusion_accounting_core',
|
||||||
'fusion_accounting_ai',
|
'fusion_accounting_ai',
|
||||||
|
'fusion_accounting_migration',
|
||||||
'account',
|
'account',
|
||||||
],
|
],
|
||||||
'data': [
|
'data': [
|
||||||
|
|||||||
@@ -4,3 +4,4 @@ from . import fusion_report_commentary
|
|||||||
from . import fusion_report_anomaly
|
from . import fusion_report_anomaly
|
||||||
from . import fusion_account_balance_mv
|
from . import fusion_account_balance_mv
|
||||||
from . import fusion_reports_cron
|
from . import fusion_reports_cron
|
||||||
|
from . import fusion_migration_wizard
|
||||||
|
|||||||
35
fusion_accounting_reports/models/fusion_migration_wizard.py
Normal file
35
fusion_accounting_reports/models/fusion_migration_wizard.py
Normal 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
|
||||||
@@ -21,3 +21,4 @@ from . import test_cron
|
|||||||
from . import test_pdf_export
|
from . import test_pdf_export
|
||||||
from . import test_xlsx_export
|
from . import test_xlsx_export
|
||||||
from . import test_period_picker
|
from . import test_period_picker
|
||||||
|
from . import test_migration_round_trip
|
||||||
|
|||||||
15
fusion_accounting_reports/tests/test_migration_round_trip.py
Normal file
15
fusion_accounting_reports/tests/test_migration_round_trip.py
Normal 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'], [])
|
||||||
Reference in New Issue
Block a user