feat(fusion_accounting_core): add computed coexistence group + recompute hooks

group_fusion_show_when_enterprise_absent has membership = all internal
users iff no Enterprise accounting module is installed. Membership is
recomputed on module install/uninstall via overrides on ir.module.module.
Used by Phase 1 fusion_bank_rec menus to auto-hide when Enterprise is
active and auto-appear after Enterprise uninstall.

Made-with: Cursor
This commit is contained in:
gsinghpal
2026-04-19 10:02:19 -04:00
parent 3f4fdeffce
commit 78a481f3f4
8 changed files with 111 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
from . import test_enterprise_detection
from . import test_shared_field_ownership
from . import test_shared_field_bank_statement
from . import test_coexistence_group

View File

@@ -0,0 +1,46 @@
from odoo.tests.common import TransactionCase, tagged
@tagged('post_install', '-at_install')
class TestCoexistenceGroup(TransactionCase):
"""The 'show when Enterprise absent' group must exist and have computed membership."""
def test_group_exists(self):
group = self.env.ref(
'fusion_accounting_core.group_fusion_show_when_enterprise_absent',
raise_if_not_found=False,
)
self.assertTrue(group, "Coexistence group must exist")
def test_membership_matches_enterprise_state(self):
"""A user is in the group iff Enterprise accounting is NOT installed.
We can't toggle Enterprise mid-test, so just assert the current state
matches: if Enterprise is installed, group should have 0 members; if
not, the group should include all internal users.
"""
group = self.env.ref(
'fusion_accounting_core.group_fusion_show_when_enterprise_absent'
)
enterprise_installed = self.env['ir.module.module']._fusion_is_enterprise_accounting_installed()
all_internal = self.env['res.users'].sudo().search([('share', '=', False)])
if enterprise_installed:
self.assertEqual(
len(group.user_ids), 0,
"Enterprise installed -> coexistence group should be empty",
)
else:
self.assertEqual(
set(group.user_ids.ids), set(all_internal.ids),
"Enterprise absent -> coexistence group should contain all internal users",
)
def test_recompute_method_exists(self):
"""The recompute helper must be callable on res.users."""
self.assertTrue(
callable(getattr(
self.env['res.users'],
'_fusion_recompute_coexistence_group',
None,
))
)