<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2016 Tecnativa S.L. - Vicent Cubells
     License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
    <record id="act_partner_registration" model="ir.actions.act_window">
        <field name="res_model">event.registration</field>
        <field name="name">Registrations</field>
        <field name="view_mode">tree,form,calendar,graph</field>
        <field name="domain">[("attendee_partner_id", "child_of", active_ids)]</field>
        <field
            name="context"
        >{'search_default_attendee_partner_id': active_id, 'default_attendee_partner_id': active_id, 'search_default_expected': True}</field>
    </record>
    <record model="ir.ui.view" id="view_partner_form_registrations">
        <field name="name">Partner Form with registrations</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form" />
        <field name="arch" type="xml">
            <div name="button_box" position="inside">
                <button
                    name="%(partner_event.act_partner_registration)d"
                    type="action"
                    class="oe_stat_button oe_inline"
                    help="Count of events with confirmed registrations."
                    icon="fa-id-card"
                >
                    <field name="registration_count" widget="statinfo" />
                </button>
            </div>
        </field>
    </record>
    <record id="view_res_partner_filter" model="ir.ui.view">
        <field name="name">res.partner.select</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_res_partner_filter" />
        <field name="arch" type="xml">
            <field name="user_id" position="after">
                <field
                    name="event_registration_ids"
                    string="Linked events"
                    filter_domain="[('event_registration_ids.event_id', 'ilike', self)]"
                />
            </field>
        </field>
    </record>
</odoo>
