"""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, )