<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!-- Allow portal users to read events where they have a registration -->
    <record id="event_registration_portal_rule" model="ir.rule">
        <field name="name">Event Registration: portal users see own registrations</field>
        <field name="model_id" ref="event.model_event_registration"/>
        <field name="domain_force">
            [('partner_id', 'child_of', [user.commercial_partner_id.id])]
        </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>

    <!-- Allow portal users to read events where they are registered -->
    <record id="event_event_portal_rule" model="ir.rule">
        <field name="name">Event Event: portal users see events with own registrations</field>
        <field name="model_id" ref="event.model_event_event"/>
        <field name="domain_force">
            [('registration_ids.partner_id', 'child_of', [user.commercial_partner_id.id])]
        </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>
</odoo>
