<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <!-- Action for smartbutton in event form view -->
    <record id="act_event_task_list" model="ir.actions.act_window">
        <field name="name">Tasks</field>
        <field name="res_model">project.task</field>
        <field name="view_mode">kanban,tree,form,calendar,pivot,graph,activity</field>
        <field name="domain">[('event_id', '=', active_id)]</field>
        <field name="search_view_id" ref="project.view_task_search_form" />
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                No tasks found. Let's create one!
            </p>
            <p>
                Keep track of the progress of your tasks from creation to completion.<br
                />
                Collaborate efficiently by chatting in real-time or via email.
            </p>
        </field>
    </record>

    <!-- Add project fields and smartbutton in event form view -->
    <record id="view_event_form" model="ir.ui.view">
        <field name="name">Add project to event</field>
        <field name="model">event.event</field>
        <field name="inherit_id" ref="event.view_event_form" />
        <field name="arch" type="xml">
            <field name="date_tz" position="after">
                <field
                    name="project_id"
                    domain="[('event_id', '=', False), ('active', '!=', False)]"
                    context="{'default_name': name, 'default_date': date_begin}"
                />
            </field>
            <div name="button_box" position="inside">
                <button
                    name="%(act_event_task_list)d"
                    type="action"
                    class="oe_stat_button"
                    icon="fa-tasks"
                    attrs="{'invisible': [('project_id','=', False)]}"
                    context="{'default_project_id': project_id}"
                >
                    <field name="count_tasks" widget="statinfo" string="Tasks" />
                </button>
            </div>
        </field>
    </record>
</odoo>
