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

    <record id="view_project_consultant_hrs_report_form" model="ir.ui.view">
        <field name="name">project.consultant.hrs.report.form</field>
        <field name="model">project.consultant.hrs.report</field>
        <field name="arch" type="xml">
            <form string="Consultant Allocation" create="false" edit="false" delete="0">
                <group>
                    <field name="project_id"/>
                    <field name="employee_id"/>
                    <field name="start_date"/>
                    <field name="end_date"/>
                    <field name="hours_type"/>
                    <field name="hours"/>
                    <field name="percentage"/>
                </group>
            </form>
        </field>
    </record>

    <record id="view_project_consultant_hrs_report_tree" model="ir.ui.view">
        <field name="name">project.consultant.hrs.report.tree</field>
        <field name="model">project.consultant.hrs.report</field>
        <field name="arch" type="xml">
            <tree string="Consultant Allocation" create="false" edit="false" delete="0">
                <field name="project_id"/>
                <field name="employee_id"/>
                <field name="start_date"/>
                <field name="end_date"/>
                <field name="hours_type"/>
                <field name="hours"/>
                <field name="percentage"/>
            </tree>
        </field>
    </record>

    <record id="view_project_consultant_hrs_report_search" model="ir.ui.view">
        <field name="name">project.consultant.hrs.report.search</field>
        <field name="model">project.consultant.hrs.report</field>
        <field name="arch" type="xml">
            <search string="Consultant Allocation">
                <field name="project_id"/>
                <field name="employee_id"/>
                <group expand="0" string="Group By">
                    <filter string="Project" name="project" domain="[]" context="{'group_by':'project_id'}"/>
                    <filter string="Consultant" name="consultant" domain="[]" context="{'group_by':'employee_id'}"/>
                    <filter string="Start Date" name="sdate" domain="[]" context="{'group_by':'start_date'}"/>
                    <filter string="End Date" name="edate" domain="[]" context="{'group_by':'end_date'}"/>
                    <filter string="Hours type" name="group_by_hours_type" context="{'group_by':'hours_type'}"/>
                    <!--<filter string="Time" name="ptime" domain="[]" context="{'group_by':'ptime'}"/>-->
                </group>
            </search>
        </field>
    </record>

    <record id="project_consultant_hrs_report_graph" model="ir.ui.view">
        <field name="name">project.consultant.hrs.report.graph</field>
        <field name="model">project.consultant.hrs.report</field>
        <field name="arch" type="xml">
            <graph string="Consultant Allocation" type="bar" stacked="False" sample="1" disable_linking="1">
                <field name="project_id" type="row"/>
                <field name="hours" type="measure"/>
            </graph>
        </field>
    </record>

    <record id="project_consultant_hrs_report_calendar" model="ir.ui.view">
        <field name="name">project.consultant.hrs.report.calendar</field>
        <field name="model">project.consultant.hrs.report</field>
        <field name="arch" type="xml">
            <calendar string="Consultant Allocation"
                date_start="start_date"
                date_stop="end_date" create="0" quick_add="False"
                mode="month">
                <field name="project_id"/>
                <field name="employee_id"/>
                <field name="start_date"/>
                <field name="end_date"/>
                <field name="hours"/>
                <field name="percentage"/>
            </calendar>
        </field>
    </record>
    <!--  create="0" quick_add="False" color="project_id" -->

    <record id="action_project_consultant_hrs_report" model="ir.actions.act_window">
        <field name="name">Consultant Allocation</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">project.consultant.hrs.report</field>
        <field name="view_mode">tree,calendar,graph</field>
        <field name="search_view_id" ref="view_project_consultant_hrs_report_search"/>
        <field name="context">{
            'search_default_project': 1,
            'search_default_consultant': 1,
            'search_default_group_by_hours_type': 1,
            'default_res_model': 'project.consultant.hrs.report'
            }
        </field>
    </record>

    <menuitem name="View Allocation" id="menu_main_cor_consult_allocation"
              action="cor_custom.action_project_consultant_hrs_report" sequence="53"
              groups="base.group_no_one,project.group_project_user"/>

    <record id="project_consul_hours_report_view_form" model="ir.ui.view">
        <field name="name">Project Consul Report Hours</field>
        <field name="model">project.project</field>
        <field name="inherit_id" ref="project.edit_project"/>
        <field name="arch" type="xml">
            <div name="button_box" position="inside">
                <button class="oe_stat_button" type="object" name="action_view_custom_project_consultant_hrs_report"
                        icon="fa-tasks"
                        attrs="{'invisible':['|',('pricing_type','!=','employee_rate'),('project_type','!=','hours_in_consultant')]}"
                        string="View Allocation" widget="statinfo">
                </button>
            </div>
        </field>
    </record>

</odoo>
