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
This commit is contained in:
gsinghpal
2026-04-19 00:51:32 -04:00
parent db90b1ad5b
commit de71a61a8b
4 changed files with 50 additions and 8 deletions

View File

@@ -7,11 +7,22 @@ class TestSafetyGuard(TransactionCase):
"""Verify the safety guard blocks Enterprise uninstall when migration hasn't run."""
def test_uninstall_not_blocked_when_migration_completed(self):
"""If the per-module migration flag is set, uninstall is allowed."""
"""If the per-module migration flag is set, uninstall is allowed.
Skip if account_accountant isn't installed -- otherwise the guard's
`if not installed: continue` short-circuit would make this test pass
vacuously without exercising the flag-check branch.
"""
Module = self.env['ir.module.module'].sudo()
if not Module.search_count([
('name', '=', 'account_accountant'),
('state', '=', 'installed'),
]):
self.skipTest("account_accountant not installed in this DB")
self.env['ir.config_parameter'].sudo().set_param(
'fusion_accounting.migration.account_accountant.completed', 'True'
)
guard = self.env['ir.module.module']._fusion_check_uninstall_guard(['account_accountant'])
guard = Module._fusion_check_uninstall_guard(['account_accountant'])
self.assertTrue(guard, "Guard should pass when migration flag is set")
def test_uninstall_blocked_when_migration_pending(self):