Files
Odoo-Modules/fusion_accounting_migration/wizards/migration_wizard.py
gsinghpal de71a61a8b fix(fusion_accounting_migration): add menu + tighten safety-guard test coverage
Addresses code review feedback on Task 17:
- Add menuitem so 'Fusion Accounting -> Migrate from Enterprise' is reachable
  (the UserError guidance now actually works). Placed at top level since
  parenting under fusion_accounting_ai.menu_fusion_accounting_root would
  require adding that module as a hard dep, which is wrong semantically
  (migration should not require AI). Both menuitems carry the admin group
  so the menu stays hidden from users who can't open the wizard anyway.
- Update the UserError wording to "Fusion Accounting -> Migrate from
  Enterprise" (no longer "Settings -> ...") to match the actual menu
  location; 'migration' is preserved per the test's assertIn check.
- Add skipTest guard to test_uninstall_not_blocked_when_migration_completed
  so it doesn't pass vacuously on Community-only CI (the guard's
  `if not installed: continue` would otherwise return True regardless of
  the flag value, giving a false green).
- Move GUARDED_MODULES import to top of wizards/migration_wizard.py
  (no circular-import risk -- models/ir_module_module.py doesn't import
  from wizards/).
- Expand docstrings on button_immediate_uninstall and module_uninstall
  overrides to note they may both fire in a single UI uninstall call
  and that the guard is idempotent (pure read + raise).

Made-with: Cursor
2026-04-19 00:51:32 -04:00

67 lines
2.5 KiB
Python

"""Migration wizard skeleton.
Per-feature migration logic (account.asset -> fusion.asset, etc.) is added
by each fusion sub-module that replaces an Enterprise feature, by extending
this wizard via _inherit.
Phase 0 ships the wizard with no migrations registered. Phase 1 will add
the bank-rec verification check. Phase 6 will add asset migration, etc.
"""
from odoo import _, api, fields, models
from ..models.ir_module_module import GUARDED_MODULES
class FusionMigrationWizard(models.TransientModel):
_name = "fusion.migration.wizard"
_description = "Migrate from Odoo Enterprise to Fusion Accounting"
enterprise_modules_detected = fields.Char(
compute='_compute_detected',
string="Enterprise Modules Detected",
)
notes = fields.Text(default=lambda self: self._default_notes())
def _default_notes(self):
return _(
"This wizard migrates data from Odoo Enterprise accounting modules "
"to Fusion Accounting tables. Run before uninstalling Enterprise. "
"After a successful run, each migrated module is marked complete "
"and the Enterprise uninstall safety guard will allow uninstall.\n\n"
"Phase 0 of the roadmap ships this wizard as a shell. As Phase 1, "
"Phase 5, Phase 6, etc. ship, each adds its own migration step here."
)
@api.depends_context('uid')
def _compute_detected(self):
Mod = self.env['ir.module.module'].sudo()
installed = Mod.search([
('name', 'in', list(GUARDED_MODULES)),
('state', '=', 'installed'),
])
for w in self:
w.enterprise_modules_detected = ', '.join(installed.mapped('name')) or _("None")
def action_run_migration(self):
"""Stub: Phase 0 has no migrations to run.
Sub-modules extend this method to perform their per-module migration,
then set the corresponding fusion_accounting.migration.<name>.completed
config param to True.
"""
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'type': 'info',
'title': _("Nothing to migrate (yet)"),
'message': _(
"Phase 0 ships the migration framework but no per-feature "
"migrations are registered yet. Each fusion sub-module that "
"replaces an Enterprise feature (Phase 1+) will register its "
"own migration step here."
),
},
}