<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data noupdate="1">
        <!-- Security Category -->
        <record id="module_category_event_rental" model="ir.module.category">
            <field name="name">Event Rental Management</field>
            <field name="description">Category for event rental management permissions.</field>
            <field name="sequence">20</field>
        </record>

        <!-- Rental User Group -->
        <record id="group_event_rental_officer" model="res.groups">
            <field name="name">Rental Officer</field>
            <field name="category_id" ref="module_category_event_rental"/>
            <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
        </record>

        <!-- Rental Manager Group -->
        <record id="group_event_rental_manager" model="res.groups">
            <field name="name">Rental Manager</field>
            <field name="category_id" ref="module_category_event_rental"/>
            <field name="implied_ids" eval="[(4, ref('group_event_rental_officer'))]"/>
            <field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
        </record>

        <!-- Record Rule: Portal Users can only see their own requests -->
        <record id="event_rental_request_portal_rule" model="ir.rule">
            <field name="name">Portal Rental Requests</field>
            <field name="model_id" ref="model_event_rental_request"/>
            <field name="domain_force">[('partner_id', '=', user.partner_id.id)]</field>
            <field name="groups" eval="[(4, ref('base.group_portal'))]"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="True"/>
            <field name="perm_create" eval="False"/>
            <field name="perm_unlink" eval="False"/>
        </record>

        <!-- Record Rule: Portal Documents can only see their own documents -->
        <record id="event_document_portal_rule" model="ir.rule">
            <field name="name">Portal Rental Documents</field>
            <field name="model_id" ref="model_event_document"/>
            <field name="domain_force">[('partner_id', '=', user.partner_id.id)]</field>
            <field name="groups" eval="[(4, ref('base.group_portal'))]"/>
            <field name="perm_read" eval="True"/>
            <field name="perm_write" eval="True"/>
            <field name="perm_create" eval="True"/>
            <field name="perm_unlink" eval="False"/>
        </record>

        <!-- Record Rule: Staff can see all requests -->
        <record id="event_rental_request_officer_rule" model="ir.rule">
            <field name="name">Officer Rental Requests</field>
            <field name="model_id" ref="model_event_rental_request"/>
            <field name="domain_force">[(1, '=', 1)]</field>
            <field name="groups" eval="[(4, ref('group_event_rental_officer'))]"/>
        </record>
    </data>
</odoo>
