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

        <!-- Search Views -->

        <record id="view_resource_resource_search" model="ir.ui.view">
            <field name="name">resource.resource.search</field>
            <field name="model">resource.resource</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Resource">
                   <group col='15' colspan='4'>
                       <field name="name"/>
                       <field name="user_id" string="User"/>
                       <field name="resource_type"/>
                       <field name="company_id" widget="selection" groups="base.group_multi_company"/>
                   </group>
                   <newline/>
                   <group expand="0" string="Group By..." colspan="4" col="20" groups="base.group_extended">
                        <filter string="User" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
                        <separator orientation="vertical"/>
                        <filter string="Type" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'resource_type'}"/>
                        <separator orientation="vertical" groups="base.group_multi_company"/>
                        <filter string="Company" icon="terp-go-home" domain="[]" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
                        <separator orientation="vertical" />
                        <filter string="Working Time" icon="terp-go-today" domain="[]" context="{'group_by':'calendar_id'}"/>
                    </group>
               </search>
            </field>
        </record>

       	<record id="view_resource_calendar_search" model="ir.ui.view">
            <field name="name">resource.calendar.search</field>
            <field name="model">resource.calendar</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Working Period">
                   <group col='15' colspan='4'>
                       <field name="name" string="Name"/>
                       <field name="manager"/>
                       <field name="company_id" widget="selection" groups="base.group_multi_company"/>
                   </group>
               </search>
            </field>
        </record>

        <record id="view_resource_calendar_leaves_search" model="ir.ui.view">
            <field name="name">resource.calendar.leaves.search</field>
            <field name="model">resource.calendar.leaves</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Working Period Leaves">
                   <group col='15' colspan='4'>
                       <field name="name" string="Reason"/>
                       <field name="resource_id" string="Resource"/>
                       <field name="company_id" string="Company" widget="selection" groups="base.group_multi_company"/>
                       <field name="calendar_id" string="Working Time" widget="selection"/>
                   </group>
                   <newline/>
                   <group expand="0" string="Group By..." colspan="4" col="20">
                        <filter string="Resource" icon="terp-personal" domain="[]" context="{'group_by':'resource_id'}"/>
                        <separator orientation="vertical"/>
                        <filter string="Company" icon="terp-go-home" domain="[]" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
                        <separator orientation="vertical" groups="base.group_multi_company"/>
                        <filter string="Date" icon="terp-go-month" domain="[]" context="{'group_by':'date_from'}" help="Starting Date of Leave"/>
                    </group>
               </search>
            </field>
        </record>

        <record id="resource_calendar_form" model="ir.ui.view">
            <field name="name">resource.calendar.form</field>
            <field name="model">resource.calendar</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Working Period">
                    <field name="name"/>
                    <field name="manager"/>
                    <field name="company_id" groups="base.group_multi_company"/>
                    <separator string="" colspan="4"/>
                    <field name="attendance_ids" colspan="4" nolabel="1"/>
                </form>
            </field>
        </record>

        <record id="view_resource_calendar_tree" model="ir.ui.view">
            <field name="name">resource.calendar.tree</field>
            <field name="model">resource.calendar</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Working Period">
                    <field name="name"/>
                    <field name="manager" select="1"/>
                    <field name="company_id" select="1" groups="base.group_multi_company"/>
                </tree>
            </field>
        </record>

        <record id="action_resource_calendar_form" model="ir.actions.act_window">
            <field name="name">Working Period</field>
            <field name="res_model">resource.calendar</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" eval="False"/>
            <field name="search_view_id" ref="view_resource_calendar_search"/>
        </record>

        <record id="view_resource_calendar_attendance_tree" model="ir.ui.view">
            <field name="name">resource.calendar.attendance.tree</field>
            <field name="model">resource.calendar.attendance</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Working Time">
                    <field name="name"/>
                    <field name="dayofweek"/>
                    <field name="hour_from" widget="float_time"/>
                    <field name="hour_to" widget="float_time"/>
                </tree>
            </field>
        </record>

        <record id="view_resource_calendar_attendance_form" model="ir.ui.view">
            <field name="name">resource.calendar.attendance.form</field>
            <field name="model">resource.calendar.attendance</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Working Time">
                    <field colspan="4" name="name" select="1"/>
                    <field name="date_from"/>
                    <field name="dayofweek" select="1"/>
                    <field name="hour_from" widget="float_time"/>
                    <field name="hour_to" widget="float_time"/>
                </form>
            </field>
        </record>

        <record id="view_resource_calendar" model="ir.ui.view">
            <field name="name">resource.calendar.leaves.calendar</field>
            <field name="model">resource.calendar.leaves</field>
            <field name="type">calendar</field>
            <field name="arch" type="xml">
                <calendar color="resource_id" date_start="date_from" string="Resource">
                    <field name="name"/>
                </calendar>
            </field>
        </record>

        <act_window
            id="resource_calendar_closing_days"
            name="Closing Days"
            res_model="resource.calendar.leaves"
            src_model="resource.calendar"
            view_mode="calendar,tree,form"
            domain="[('calendar_id','=',active_id), ('resource_id','=',False)]"/>

        <act_window
            id="resource_calendar_resources_leaves"
            name="Resources Leaves"
            res_model="resource.calendar.leaves"
            src_model="resource.calendar"
            view_mode="calendar,tree,form"
            domain="[('calendar_id','=',active_id), ('resource_id','!=',False)]"/>

        <record id="resource_resource_form" model="ir.ui.view">
            <field name="name">resource.resource.form</field>
            <field name="model">resource.resource</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Resource">
                    <field name="name" />
                    <field name="user_id" attrs="{'required':[('resource_type','=','user')]}"/>
                    <field name="company_id" widget="selection" groups="base.group_multi_company"/>
                    <field name="resource_type" />
                    <field name="calendar_id" widget="selection"/>
                    <field name="time_efficiency" groups="base.group_extended"/>
                    <field name="active"/>
                </form>
            </field>
        </record>

        <record id="resource_resource_tree" model="ir.ui.view">
            <field name="name">resource.resource.tree</field>
            <field name="model">resource.resource</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Resources">
                    <field name="name" />
                    <field name="user_id" />
                    <field name="company_id" groups="base.group_multi_company"/>
                    <field name="resource_type" />
                    <field name="calendar_id" />
                    <field name="time_efficiency" groups="base.group_extended"/>
                </tree>
            </field>
        </record>

        <record id="action_resource_resource_tree" model="ir.actions.act_window">
            <field name="name">Resources</field>
            <field name="res_model">resource.resource</field>
            <field name="view_mode">tree,form</field>
            <field name="context">{}</field>
            <field name="search_view_id" ref="view_resource_resource_search"/>
            <field name="help">There you can find clusters of your resources type involved in a specific project phase as well as their workload.</field>
        </record>

        <record id="resource_calendar_leave_form" model="ir.ui.view">
            <field name="name">resource.calendar.leaves.form</field>
            <field name="model">resource.calendar.leaves</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Leave Detail">
                    <group colspan="4" col="6">
                       <group colspan="2" col="2">
                           <field name="resource_id" on_change="onchange_resource(resource_id)"/>
                           <field name="name" string="Reason"/>
                       </group>
                       <group colspan="2" col="2">
                           <field name="date_from"/>
                           <field name="calendar_id"/>
                           <field name="company_id" widget="selection" groups="base.group_multi_company"/>
                       </group>
                       <group colspan="2" col="2">
                           <field name="date_to"/>
                       </group>
                   </group>
                </form>
            </field>
        </record>
        <record id="resource_calendar_leave_tree" model="ir.ui.view">
            <field name="name">resource.calendar.leaves.tree</field>
            <field name="model">resource.calendar.leaves</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Leave Detail">
                    <field name="name" string="Reason"/>
                    <field name="resource_id" />
                    <field name="company_id" groups="base.group_multi_company"/>
                    <field name="calendar_id" />
                    <field name="date_from" />
                    <field name="date_to" />
                </tree>
            </field>
        </record>
        <record id="action_resource_calendar_leave_tree" model="ir.actions.act_window">
            <field name="name">Resource Leaves</field>
            <field name="res_model">resource.calendar.leaves</field>
            <field name="view_mode">tree,form,calendar</field>
            <field name="search_view_id" ref="view_resource_calendar_leaves_search"/>
        </record>

    </data>
</openerp>
