<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data noupdate="0">

        <record id="group_fusion_inventory_user" model="res.groups">
            <field name="name">Fusion Inventory / User</field>
            <field name="implied_ids" eval="[(4, ref('stock.group_stock_user'))]"/>
        </record>

        <record id="group_fusion_inventory_manager" model="res.groups">
            <field name="name">Fusion Inventory / Manager</field>
            <field name="implied_ids" eval="[(4, ref('group_fusion_inventory_user'))]"/>
        </record>

        <!-- Admins automatically get Manager access (group_user is noupdate=1, handled by post_init_hook) -->
        <record id="base.group_system" model="res.groups">
            <field name="implied_ids" eval="[(4, ref('group_fusion_inventory_manager'))]"/>
        </record>

    </data>

    <data noupdate="1">

        <record id="rule_booking_own" model="ir.rule">
            <field name="name">Fusion Inventory: Own Bookings Only</field>
            <field name="model_id" ref="model_fusion_inventory_booking"/>
            <field name="domain_force">[('user_id', '=', user.id)]</field>
            <field name="groups" eval="[(4, ref('group_fusion_inventory_user'))]"/>
        </record>

        <record id="rule_booking_manager" model="ir.rule">
            <field name="name">Fusion Inventory: Manager Sees All Bookings</field>
            <field name="model_id" ref="model_fusion_inventory_booking"/>
            <field name="domain_force">[(1, '=', 1)]</field>
            <field name="groups" eval="[(4, ref('group_fusion_inventory_manager'))]"/>
        </record>

        <record id="rule_booking_portal" model="ir.rule">
            <field name="name">Fusion Inventory: Portal Booking Read</field>
            <field name="model_id" ref="model_fusion_inventory_booking"/>
            <field name="domain_force">[(1, '=', 1)]</field>
            <field name="groups" eval="[(4, ref('base.group_portal'))]"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="False"/>
            <field name="perm_create" eval="False"/>
            <field name="perm_unlink" eval="False"/>
        </record>

    </data>
</odoo>
