refactor(fusion_accounting): move security groups to _core, add multi-company session rule
Made-with: Cursor
This commit is contained in:
@@ -24,6 +24,7 @@ Built by Nexa Systems Inc.
|
||||
'maintainer': 'Nexa Systems Inc.',
|
||||
'depends': ['account', 'mail'],
|
||||
'data': [
|
||||
'security/fusion_accounting_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'installable': True,
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<!-- Module Category -->
|
||||
<record id="module_category_fusion_accounting" model="ir.module.category">
|
||||
<field name="name">Fusion Accounting</field>
|
||||
<field name="sequence">25</field>
|
||||
</record>
|
||||
|
||||
<!-- Groups Privilege -->
|
||||
<record id="res_groups_privilege_fusion_accounting" model="res.groups.privilege">
|
||||
<field name="name">Fusion Accounting</field>
|
||||
<field name="category_id" ref="module_category_fusion_accounting"/>
|
||||
</record>
|
||||
|
||||
<!-- User Group (Staff) -->
|
||||
<record id="group_fusion_accounting_user" model="res.groups">
|
||||
<field name="name">User</field>
|
||||
<field name="sequence">10</field>
|
||||
<field name="implied_ids" eval="[(4, ref('account.group_account_user'))]"/>
|
||||
<field name="privilege_id" ref="res_groups_privilege_fusion_accounting"/>
|
||||
</record>
|
||||
|
||||
<!-- Manager Group -->
|
||||
<record id="group_fusion_accounting_manager" model="res.groups">
|
||||
<field name="name">Manager</field>
|
||||
<field name="sequence">20</field>
|
||||
<field name="implied_ids" eval="[(4, ref('group_fusion_accounting_user'))]"/>
|
||||
<field name="privilege_id" ref="res_groups_privilege_fusion_accounting"/>
|
||||
</record>
|
||||
|
||||
<!-- Admin Group -->
|
||||
<record id="group_fusion_accounting_admin" model="res.groups">
|
||||
<field name="name">Administrator</field>
|
||||
<field name="sequence">30</field>
|
||||
<field name="implied_ids" eval="[(4, ref('group_fusion_accounting_manager'))]"/>
|
||||
<field name="privilege_id" ref="res_groups_privilege_fusion_accounting"/>
|
||||
</record>
|
||||
|
||||
<!-- Auto-assign: Accounting users get Fusion User; Advisers get Admin -->
|
||||
<record id="account.group_account_user" model="res.groups">
|
||||
<field name="implied_ids" eval="[(4, ref('group_fusion_accounting_user'))]"/>
|
||||
</record>
|
||||
<record id="account.group_account_manager" model="res.groups">
|
||||
<field name="implied_ids" eval="[(4, ref('group_fusion_accounting_admin'))]"/>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user