<?xml version="1.0" ?>
<openerp>
    <data>

        <!-- Holidays -->
        <record model="ir.ui.view" id="edit_holiday_new">
            <field name="name">hr.holidays.form</field>
            <field name="model">hr.holidays</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Employee Holidays">
                    <field name="name" select="1"/>
                    <field name="holiday_status" select="1"/>
                    <field name="date_from" select="1"/>
                    <field name="date_to" select="1" on_change="onchange_date_to(date_from, date_to)"/>
                    <notebook colspan="4">
                        <page string="General">
                            <field name="employee_id" select="1" />
                            <field name="number_of_days"/>
                            <field name="manager_id"/>
                            <field name="notes" colspan="4"/>
                            <newline/>
                            <field name="state" select="1" colspan="2"/>
                            <group colspan="2">
                                <button string="Confirm" name="confirm" states="draft" type="workflow"/>
                                <button string="Validate" name="validate" states="confirm" type="workflow"/>
                                <button string="Refuse" name="refuse" states="confirm" type="workflow"/>
                                <button string="Cancel" name="cancel" states="validate,refuse" type="workflow"/>
                                <button string="Set to Draft" name="set_to_draft" states="cancel" type="object"/>
                            </group>
                        </page>
                    </notebook>
                </form>
            </field>
        </record>

        <record model="ir.ui.view" id="view_holiday">
            <field name="name">hr.holidays.tree</field>
            <field name="model">hr.holidays</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Employee Holidays">
                    <field name="name"/>
                    <field name="employee_id"/>
                    <field name="number_of_days" string="Number of Days"/>
                    <field name="date_from"/>
                    <field name="date_to"/>
                    <field name="holiday_status"/>
                    <field name="state"/>
                </tree>
            </field>
        </record>

        <!-- holidays status -->
        <record model="ir.ui.view" id="edit_holiday_status_form">
            <field name="name">hr.holidays.status.form</field>
            <field name="model">hr.holidays.status</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Define holiday status">
                    <field colspan="4" name="name" select="1"/>
                    <field name="color_name" select="2"/>
                    <field name="section_id"  select="1" />
                    <field name="limit" select="2"/>
                    <field name="active" select="2"/>
                </form>
            </field>
        </record>
        <record model="ir.ui.view" id="view_holiday_status_tree">
            <field name="name">hr.holidays.status.tree</field>
            <field name="model">hr.holidays.status</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Holiday status">
                    <field name="name"/>
                    <field name="color_name" />
                    <field name="section_id" />
                    <field name="limit" />
                    <field name="active" />
                </tree>
            </field>
        </record>
        <record id="open_view_holiday_status" model="ir.actions.act_window">
            <field name="name">Holiday Status</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">hr.holidays.status</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
        </record>
        <menuitem
            action="open_view_holiday_status"
            id="menu_open_view_holiday_status"
            parent="hr.menu_hr_configuration"/>

        <!-- holidays per user -->
        <record model="ir.ui.view" id="view_holidays_per_user_form">
            <field name="name">hr.holidays.per.user.form</field>
            <field name="model">hr.holidays.per.user</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
            	<form string="Holidays Per Employee">
            		<group>
	                    <field name="employee_id" select="1" />
	                    <field name="holiday_status" select="1" />
						<field name="max_leaves" select="2" />
						<field name="active" select="2"/>
            		</group>
	            	<notebook colspan="4">
	            		<page string="General Information">
		                    <field name="leaves_taken" select="2" />
		                    <field name="remaining_leaves" select="2" colspan="2" />
		                    <newline/>
		                    <field name="notes" colspan="4" select="2"/>
		              	</page>
		              	<page string="Holidays" >
		              		<field name="holiday_ids" nolabel="1">
                                <tree string="Employee Holidays">
                                    <field name="name"/>
                                    <field name="number_of_days" string="Number of Days"/>
                                    <field name="date_from"/>
                                    <field name="date_to"/>
                                    <field name="holiday_status"/>
                                    <field name="state"/>
                                </tree>
                            </field>
		              	</page>
	                </notebook>
                </form>
            </field>
        </record>
        <record model="ir.ui.view" id="view_holidays_per_user_tree">
            <field name="name">hr.holidays.per.user.tree</field>
            <field name="model">hr.holidays.per.user</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Holidays Per Employee">
                    <field name="employee_id"/>
                    <field name="holiday_status"/>
                    <field name="max_leaves"/>
                    <field name="remaining_leaves"/>
                    <field name="active"/>
                </tree>
            </field>
        </record>

        <record model="ir.ui.view" id="view_holidays_per_user_graph">
            <field name="name">hr.holidays.per.user.graph</field>
            <field name="model">hr.holidays.per.user</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
            <graph type="bar" string="Holidays Allowed">
                <field name="employee_id"/>
                <field name="max_leaves" operator="+"/>
                <field name="leaves_taken" operator="+"/>
            </graph>
        </field>
        </record>

        <!-- Menu Items -->
        <record model="ir.actions.act_window" id="open_ask_holidays">
            <field name="res_model">hr.holidays</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="edit_holiday_new" />
        </record>

        <menuitem
            name="Holidays Management"
            parent="hr.menu_hr_root"
            id="menu_open_ask_holidays"/>

        <menuitem
            name="New Holidays Request"
            parent="menu_open_ask_holidays"
            id="menu_open_ask_holidays_new"
            action="open_ask_holidays"/>

        <record model="ir.actions.act_window" id="action_all_holiday">
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">hr.holidays</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
        </record>
        <menuitem name="All Holidays Requests"
            parent="menu_open_ask_holidays"
            id="menu_action_all_holiday"
            action="action_all_holiday"
            groups="hr.group_hr_manager"/>

        <record model="ir.actions.act_window" id="action_my_holiday">
            <field name="name">My Holidays Request</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">hr.holidays</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[('user_id','=',uid)]</field>
        </record>
        <menuitem name="My Holidays Requests" parent="menu_open_ask_holidays" id="menu_action_my_holiday" action="action_my_holiday" />

        <record model="ir.actions.act_window" id="action_my_holiday_draft">
            <field name="name">My Holidays Request Draft</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">hr.holidays</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[('user_id','=',uid), ('state','=','draft')]</field>
        </record>
        <menuitem name="My Draft Holidays Requests" parent="menu_action_my_holiday" id="menu_action_my_holiday_draft" action="action_my_holiday_draft" />

        <record model="ir.actions.act_window" id="action_my_holiday_waiting">
            <field name="name">My Awaiting Confirmation Holidays Requests</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">hr.holidays</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[('user_id','=',uid), ('state','=','confirm')]</field>
        </record>
        <menuitem parent="menu_action_my_holiday" id="menu_action_my_holiday_waiting" action="action_my_holiday_waiting" />

        <record model="ir.actions.act_window" id="action_my_holiday_validate">
            <field name="name">My Holidays Request Validated</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">hr.holidays</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[('user_id','=',uid), ('state','=','validate')]</field>
        </record>
        <menuitem name="My Validated Holidays Requests" parent="menu_action_my_holiday" id="menu_action_my_holiday_validate" action="action_my_holiday_validate" />

        <record model="ir.actions.act_window" id="action_my_holiday_refuse">
            <field name="name">My Holidays Request Refused</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">hr.holidays</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[('user_id','=',uid), ('state','=','refuse')]</field>
        </record>
        <menuitem name="My Refused Holidays Requests" parent="menu_action_my_holiday" id="menu_action_my_holiday_refuse" action="action_my_holiday_refuse" />

        <record model="ir.actions.act_window" id="action_holiday_waiting">
            <field name="name">Requests Awaiting for Validation</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">hr.holidays</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[('state','=','confirm')]</field>
        </record>
        <menuitem name="Holidays Requests Awaiting for Validation" parent="menu_action_all_holiday" id="menu_action_holiday_waiting" action="action_holiday_waiting" />

        <record model="ir.actions.act_window" id="action_holidays_per_user">
            <field name="name">Holidays Per Employee</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">hr.holidays.per.user</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form,graph</field>
        </record>
        <menuitem name="Holidays Per Employee" parent="hr.menu_hr_configuration" id="menu_open_holidays_per_user" action="action_holidays_per_user"/>

        <record model="ir.actions.act_window" id="action_my_holiday_available">
            <field name="name">My Available Holidays</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">hr.holidays.per.user</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree</field>
            <field name="domain">[('user_id','=',uid)]</field>
        </record>
        <menuitem name="My Available Holidays" parent="hr.menu_hr_reporting" id="menu_action_my_holiday_available" action="action_my_holiday_available" />


    <!--  Shortcuts -->
        <act_window name="My Holiday Requests"
            domain="[('employee_id', '=', active_id)]"
            res_model="hr.holidays"
            src_model="hr.employee"
            id="act_hr_employee_holiday_request"/>

    </data>
</openerp>
