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
43 lines
1.9 KiB
Python
43 lines
1.9 KiB
Python
from odoo.exceptions import UserError
|
|
from odoo.tests.common import TransactionCase, tagged
|
|
|
|
|
|
@tagged('post_install', '-at_install')
|
|
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.
|
|
|
|
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 = 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):
|
|
"""If account_accountant is installed and migration not run, raise."""
|
|
self.env['ir.config_parameter'].sudo().set_param(
|
|
'fusion_accounting.migration.account_accountant.completed', 'False'
|
|
)
|
|
Module = self.env['ir.module.module'].sudo()
|
|
installed = Module.search_count([
|
|
('name', '=', 'account_accountant'),
|
|
('state', '=', 'installed'),
|
|
])
|
|
if not installed:
|
|
self.skipTest("account_accountant not installed in this DB")
|
|
with self.assertRaises(UserError) as ctx:
|
|
Module._fusion_check_uninstall_guard(['account_accountant'])
|
|
self.assertIn('migration', str(ctx.exception).lower())
|