feat(fusion_accounting_core): add _fusion_is_enterprise_accounting_installed helper
Made-with: Cursor
This commit is contained in:
@@ -1 +1 @@
|
|||||||
# Models populated in Tasks 8-12 (shared-field-ownership, helpers)
|
from . import ir_module_module
|
||||||
|
|||||||
32
fusion_accounting_core/models/ir_module_module.py
Normal file
32
fusion_accounting_core/models/ir_module_module.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
from odoo import api, models
|
||||||
|
|
||||||
|
|
||||||
|
# Modules considered "Odoo Enterprise accounting" for the purpose of feature gating.
|
||||||
|
# A client is "on Enterprise" if any of these are installed; fusion_accounting_*
|
||||||
|
# replacement modules will hide their menus when Enterprise is present (replace mode
|
||||||
|
# vs. augment mode is configurable in Settings).
|
||||||
|
ENTERPRISE_ACCOUNTING_MODULES = (
|
||||||
|
'account_accountant',
|
||||||
|
'account_reports',
|
||||||
|
'accountant',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class IrModuleModule(models.Model):
|
||||||
|
_inherit = "ir.module.module"
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _fusion_is_enterprise_accounting_installed(self):
|
||||||
|
"""True if any Odoo Enterprise accounting module is installed in this DB."""
|
||||||
|
return bool(self.sudo().search_count([
|
||||||
|
('name', 'in', list(ENTERPRISE_ACCOUNTING_MODULES)),
|
||||||
|
('state', '=', 'installed'),
|
||||||
|
]))
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _fusion_is_module_installed(self, module_name):
|
||||||
|
"""True if a specific module is installed."""
|
||||||
|
return bool(self.sudo().search_count([
|
||||||
|
('name', '=', module_name),
|
||||||
|
('state', '=', 'installed'),
|
||||||
|
]))
|
||||||
@@ -1 +1 @@
|
|||||||
# Tests populated in Tasks 8-12
|
from . import test_enterprise_detection
|
||||||
|
|||||||
20
fusion_accounting_core/tests/test_enterprise_detection.py
Normal file
20
fusion_accounting_core/tests/test_enterprise_detection.py
Normal 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)
|
||||||
Reference in New Issue
Block a user