<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <!-- planning.slot views -->
    <record id="planning_slot_view_tree" model="ir.ui.view">
        <field name="name">planning.slot.tree</field>
        <field name="model">planning.slot</field>
        <field name="inherit_id" ref="planning.planning_view_tree"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='employee_id']" position="before">
                <field name="project_id"/> <!-- optional="hide" -->
                <field name="task_id"/>
            </xpath>
            <xpath expr="//field[@name='allocated_hours']" position="after">
                <field name="budgeted_hours"/>
                <field name="rem_all_hours"/>
            </xpath>
        </field>
    </record>

    <record id="planning_slot_view_form" model="ir.ui.view">
        <field name="name">planning.slot.form</field>
        <field name="model">planning.slot</field>
        <field name="inherit_id" ref="planning.planning_view_form"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='employee_id']" position="before">
                <field name="project_id" context="{'default_allow_forecast': True}"/>
                <field name="task_id" attrs="{'invisible': [('project_id', '=', False)]}"/>
            </xpath>
            <xpath expr="//field[@name='employee_id']" position="after">
                <field name="budgeted_hours"/>
                <field name="rem_all_hours"/>
            </xpath>
        </field>
    </record>

    <record id="planning_slot_view_search" model="ir.ui.view">
        <field name="name">planning.slot.search</field>
        <field name="model">planning.slot</field>
        <field name="inherit_id" ref="planning.planning_view_search"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='role_id']" position="after">
                <field name="project_id"/>
                <field name="task_id"/>
            </xpath>
            <xpath expr="//filter[@name='group_by_role']" position="after">
                <filter name="group_by_project" string="Project" context="{'group_by': 'project_id'}"/>
                <filter name="group_by_task" string="Task" context="{'group_by': 'task_id'}"/>
            </xpath>
        </field>
    </record>

    <!-- actions -->
    <record id="planning_action_schedule_by_project" model="ir.actions.act_window">
        <field name="name">Planning Schedule</field>
        <field name="res_model">planning.slot</field>
        <field name="view_mode">gantt,calendar,tree,form</field>
        <field name="context">{'search_default_group_by_project': 1, 'planning_expand_project': 1}</field>
    </record>

        <record id="planning_action_schedule_by_project_view_gantt" model="ir.actions.act_window.view">
            <field name="sequence" eval="1"/>
            <field name="view_mode">gantt</field>
            <field name="view_id" ref="planning.planning_view_gantt"/>
            <field name="act_window_id" ref="planning_action_schedule_by_project"/>
        </record>

    <!-- menus -->
    <menuitem
        id="planning_menu_schedule_by_project"
        name="By Project"
        sequence="30"
        parent="planning.planning_menu_schedule"
        action="planning_action_schedule_by_project"/>

</odoo>