<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <record id="project_sprint_view_form" model="ir.ui.view">
        <field name="name">project.sprint.view.form</field>
        <field name="model">project.sprint</field>
        <field name="arch" type="xml">
            <form>
                <header>
                    <button
                        name="action_start"
                        string="Start"
                        type="object"
                        states="draft"
                        class="btn btn-primary"
                    />
                    <button
                        name="action_done"
                        string="Done"
                        type="object"
                        states="in_progress"
                        class="btn btn-primary"
                    />
                    <field
                        name="state"
                        widget="statusbar"
                        statusbar_visible="draft,in_progress,done"
                    />
                </header>
                <sheet>
                    <div class="oe_button_box" name="button_box">
                        <button
                            name="action_tasks"
                            type="object"
                            class="oe_stat_button"
                            icon="fa-tasks"
                        >
                            <div class="o_field_widget o_stat_info">
                                <span class="o_stat_value">
                                    <field name="tasks_count" nolabel="1" />
                                </span>
                                <span class="o_stat_text">
                                Tasks
                            </span>
                            </div>
                        </button>
                    </div>
                    <label for="name" class="oe_edit_only " />
                    <h1>
                        <field name="name" />
                    </h1>
                    <group>
                        <group>
                            <field name="user_ids" widget="many2many_avatar_user" />
                            <field name="project_id" />
                        </group>
                        <group>
                            <field name="date_start" />
                            <field name="date_option" />
                            <field
                                name="date_end"
                                attrs="{'readonly' : [('date_option', '!=', 'custom')]}"
                                force_save="1"
                            />
                        </group>
                        <field name="description" />
                    </group>
                </sheet>
                <div class="oe_chatter">
                    <field name="message_follower_ids" widget="mail_followers" />
                    <field name="activity_ids" widget="mail_activity" />
                    <field name="message_ids" widget="mail_thread" />
                </div>
            </form>
        </field>
    </record>
    <record id="project_sprint_view_tree" model="ir.ui.view">
        <field name="name">project.sprint.view.tree</field>
        <field name="model">project.sprint</field>
        <field name="arch" type="xml">
            <tree>
                <field name="name" />
                <field name="project_id" />
                <field name="date_start" />
                <field name="date_end" />
                <field name="state" />
            </tree>
        </field>
    </record>
    <record id="project_sprint_view_search" model="ir.ui.view">
        <field name="name">project.sprint.view.search</field>
        <field name="model">project.sprint</field>
        <field name="arch" type="xml">
            <search>
                <field name="name" />
                <field name="project_id" />
                <field name="description" />
                <separator />
                <filter
                    string="Draft"
                    name="draft"
                    domain="[('state', '=', 'draft')]"
                />
                <filter
                    string="In Progress"
                    name="progress"
                    domain="[('state', '=', 'in_progress')]"
                />
                <filter string="Done" name="done" domain="[('state', '=', 'done')]" />
                <separator />
                <filter name="date_start" string="Date Start" date="date_start" />
                <filter name="date_end" string="Date End" date="date_end" />
                <separator />
                <group expand="0" string="Group By">
                    <filter
                        name="project_id"
                        string="Project"
                        context="{'group_by':'project_id'}"
                    />
                    <filter
                        name="state"
                        string="State"
                        context="{'group_by':'state'}"
                    />
                </group>
            </search>
        </field>
    </record>
    <record id="view_sprint_timeline" model="ir.ui.view">
        <field name="model">project.sprint</field>
        <field name="type">timeline</field>
        <field name="arch" type="xml">
            <timeline
                date_start="date_start"
                date_stop="date_end"
                string="Sprints"
                default_group_by="project_id"
                event_open_popup="true"
            >
                <templates>
                    <t t-name="timeline-item">
                        <div class="o_project_timeline_item">
                            <span name="display_name">
                                <t t-esc="record.display_name" />
                            </span>
                        </div>
                    </t>
                </templates>
            </timeline>
        </field>
    </record>
    <record id="project_sprint_action" model="ir.actions.act_window">
        <field name="name">Sprints</field>
        <field name="res_model">project.sprint</field>
        <field name="view_mode">timeline,tree,form</field>
    </record>
    <menuitem
        id="project_sprint_menu"
        name="Sprints"
        parent="project.menu_project_config"
        action="project_sprint_action"
        sequence="10"
    />
</odoo>
