<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!-- ================================================================== -->
    <!-- MODULE CATEGORY (required for user settings section rendering)    -->
    <!-- Odoo 19 organizes privileges by ir.module.category.              -->
    <!-- Without this, groups fall into the generic Extra Rights list.     -->
    <!-- ================================================================== -->
    <record id="module_category_fusion_claims" model="ir.module.category">
        <field name="name">Fusion Claims</field>
        <field name="sequence">45</field>
    </record>

    <!-- ================================================================== -->
    <!-- FUSION CLAIMS PRIVILEGE (Odoo 19 pattern)                          -->
    <!-- Linked to module_category_fusion_claims so all groups appear       -->
    <!-- under a "FUSION CLAIMS" section in user settings.                  -->
    <!-- ================================================================== -->
    <record id="res_groups_privilege_fusion_claims" model="res.groups.privilege">
        <field name="name">Fusion Claims</field>
        <field name="sequence">45</field>
        <field name="category_id" ref="module_category_fusion_claims"/>
    </record>

    <!-- ================================================================== -->
    <!-- USER GROUP                                                          -->
    <!-- Implies sales_team.group_sale_salesman so existing access rules     -->
    <!-- continue working without changes to ir.model.access.csv             -->
    <!-- ================================================================== -->
    <record id="group_fusion_claims_user" model="res.groups">
        <field name="name">User</field>
        <field name="sequence">10</field>
        <field name="implied_ids" eval="[(4, ref('base.group_user')), (4, ref('sales_team.group_sale_salesman'))]"/>
        <field name="privilege_id" ref="res_groups_privilege_fusion_claims"/>
    </record>

    <!-- ================================================================== -->
    <!-- MANAGER GROUP                                                       -->
    <!-- ================================================================== -->
    <record id="group_fusion_claims_manager" model="res.groups">
        <field name="name">Administrator</field>
        <field name="sequence">20</field>
        <field name="privilege_id" ref="res_groups_privilege_fusion_claims"/>
        <field name="implied_ids" eval="[(4, ref('group_fusion_claims_user')), (4, ref('sales_team.group_sale_manager'))]"/>
        <field name="user_ids" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
    </record>

    <!-- DOCUMENT LOCK OVERRIDE GROUP                                        -->
    <!-- Only users in this group can edit locked documents when the          -->
    <!-- "Allow Document Lock Override" setting is enabled.                   -->
    <!-- Not implied by Manager. Must be explicitly assigned.                -->
    <record id="group_document_lock_override" model="res.groups">
        <field name="name">Fusion: Document Lock Override</field>
        <field name="privilege_id" eval="False"/>
        <field name="comment">Temporary permission for editing locked documents on old/legacy cases. Requires the "Allow Document Lock Override" setting to be enabled in Fusion Claims Settings. Once all legacy cases are handled, disable the setting and remove this permission from users.</field>
    </record>


</odoo>
