This commit is contained in:
gsinghpal
2026-05-16 13:18:52 -04:00
parent 191a9c82be
commit 9ebf89bde2
1080 changed files with 0 additions and 1197 deletions

View File

@@ -0,0 +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,
))
)

View File

@@ -0,0 +1,20 @@
from odoo.tests.common import TransactionCase, tagged
@tagged('post_install', '-at_install')
class TestEnterpriseDetection(TransactionCase):
"""Verify the helper that detects Odoo Enterprise accounting installs."""
def test_helper_returns_bool(self):
result = self.env['ir.module.module']._fusion_is_enterprise_accounting_installed()
self.assertIsInstance(result, bool)
def test_helper_matches_actual_state(self):
"""Helper should return True iff one of the known Enterprise modules is installed."""
installed = self.env['ir.module.module'].sudo().search_count([
('name', 'in', ['account_accountant', 'account_reports', 'accountant']),
('state', '=', 'installed'),
])
expected = bool(installed)
actual = self.env['ir.module.module']._fusion_is_enterprise_accounting_installed()
self.assertEqual(actual, expected)

View File

@@ -0,0 +1,14 @@
from odoo.tests.common import TransactionCase, tagged
@tagged('post_install', '-at_install')
class TestSharedFieldBankStatementLine(TransactionCase):
"""Verify fusion_accounting_core declares the Enterprise extension fields
on account.bank.statement.line so they survive Enterprise uninstall."""
def test_cron_last_check_field_exists(self):
Line = self.env['account.bank.statement.line']
self.assertIn('cron_last_check', Line._fields,
"cron_last_check must be declared on account.bank.statement.line "
"(shared-field-ownership with account_accountant)")
self.assertEqual(Line._fields['cron_last_check'].type, 'datetime')

View File

@@ -0,0 +1,32 @@
from odoo.tests.common import TransactionCase, tagged
@tagged('post_install', '-at_install')
class TestSharedFieldOwnership(TransactionCase):
"""Verify fusion_accounting_core declares the Enterprise extension fields
on account.move and account.reconcile.model, so they survive Enterprise uninstall."""
def test_account_move_deferred_fields_exist(self):
Move = self.env['account.move']
for fname in ('deferred_move_ids', 'deferred_original_move_ids', 'deferred_entry_type'):
self.assertIn(fname, Move._fields, f"{fname!r} must exist on account.move")
def test_account_move_signing_user_exists(self):
Move = self.env['account.move']
self.assertIn('signing_user', Move._fields)
def test_account_move_payment_state_before_switch_exists(self):
Move = self.env['account.move']
self.assertIn('payment_state_before_switch', Move._fields)
def test_account_reconcile_model_created_automatically_exists(self):
Model = self.env['account.reconcile.model']
self.assertIn('created_automatically', Model._fields)
def test_deferred_relation_table_name_matches_enterprise(self):
"""The shared M2M relation table must be named identically to Enterprise's
so dual ownership works (Enterprise drops field => fusion preserves table)."""
f = self.env['account.move']._fields['deferred_move_ids']
self.assertEqual(f.relation, 'account_move_deferred_rel')
self.assertEqual(f.column1, 'original_move_id')
self.assertEqual(f.column2, 'deferred_move_id')