refactor(fusion_accounting): move security groups to _core, add multi-company session rule

Made-with: Cursor
This commit is contained in:
gsinghpal
2026-04-19 00:14:36 -04:00
parent 10140a6968
commit 7ac01991e5
13 changed files with 237 additions and 151 deletions

View File

@@ -0,0 +1,48 @@
"""Reassign security group/category/privilege xml-ids from the old module name.
Pre-Phase-0, the three fusion security groups (user, manager, admin), the
module category and the privilege all lived in module='fusion_accounting'.
Post-Phase-0 (Task 16) they moved into module='fusion_accounting_core'.
Odoo loads the XML from the new location on upgrade, but the existing
ir_model_data rows still reference the old module. This script rewrites them.
Both fusion_accounting_core and fusion_accounting_ai ship an equivalent
UPDATE — whichever post-migration runs first wins the rehoming, the other
is a no-op. This redundancy protects the common case where the two modules
are upgraded in either order (as well as the case where only one is
installed in a given database).
Idempotent: running it a second time matches zero rows.
"""
import logging
_logger = logging.getLogger(__name__)
CORE_SECURITY_NAMES = (
'module_category_fusion_accounting',
'res_groups_privilege_fusion_accounting',
'group_fusion_accounting_user',
'group_fusion_accounting_manager',
'group_fusion_accounting_admin',
)
def migrate(cr, version):
cr.execute(
"""
UPDATE ir_model_data
SET module = 'fusion_accounting_core'
WHERE module = 'fusion_accounting'
AND name = ANY(%s)
""",
(list(CORE_SECURITY_NAMES),),
)
moved = cr.rowcount
_logger.info(
"fusion_accounting_core post-migration: reassigned %d security rows "
"from module='fusion_accounting' to module='fusion_accounting_core'",
moved,
)