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

        <record id="view_attendance_form" model="ir.ui.view">
            <field name="name">hr.attendance.form</field>
            <field name="model">hr.attendance</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Employee attendance">
                    <field name="employee_id"  />
                    <field name="name"  />
                    <field name="action"  />
                    <field name="action_desc"  />
                </form>
            </field>
        </record>

        <record id="view_attendance_tree" model="ir.ui.view">
            <field name="name">hr.attendance.tree</field>
            <field name="model">hr.attendance</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Employee attendances">
                    <field name="name"/>
                    <field name="action"/>
                    <field name="action_desc"/>
                </tree>
            </field>
        </record>

        <record id="view_attendance_who" model="ir.ui.view">
            <field name="name">hr.attendance.tree</field>
            <field name="model">hr.attendance</field>
            <field name="type">tree</field>
            <field eval="3" name="priority"/>
            <field name="arch" type="xml">
                <tree string="Employee attendance">
                    <field name="employee_id"/>
                    <field name="name"/>
                    <field name="action"/>
                    <field name="day" invisible="1"/>
                </tree>
            </field>
        </record>

        <record model="ir.ui.view" id="view_hr_attendance_filter">
            <field name="name">view_hr_attendance_filter</field>
            <field name="model">hr.attendance</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Hr Attendance Search">
                    <filter icon="terp-stock_align_left_24" string="My Attendances" domain="[('employee_id.user_id.id', '=', uid)]" />
                    <separator orientation="vertical"/>
                    <filter icon="terp-go-today" string="Today" domain="[('name::date','=',current_date)]" />
                    <separator orientation="vertical"/>
                    <field name="employee_id"   />
                    <field name="name"    />
                    <field name="action"   />
                    <newline/>
                    <group expand="0" string="Group By...">
                        <filter name="employee" string="Employee" icon="terp-personal" domain="[]" context="{'group_by':'employee_id'}"/>
                        <separator orientation="vertical"/>
                        <filter string="Day" icon="terp-go-today" domain="[]" context="{'group_by':'day'}"/>
                    </group>
                </search>
            </field>
        </record>

        <record id="open_view_attendance" model="ir.actions.act_window">
            <field name="name">Attendances</field>
            <field name="res_model">hr.attendance</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="context">{"search_default_employee":1}</field>
            <field name="search_view_id" ref="view_hr_attendance_filter" />
            <field name="help">Time Tracking functionality aims to manage employee's attendances on the basis of the actions (Sign in/Sign out) performed by them. You can also link this to an attendance machine using OpenERP's webservices features.</field>
        </record>

        <menuitem id="menu_hr_time_tracking" name="Time Tracking" parent="hr.menu_hr_root" sequence="3"/>
        <menuitem action="open_view_attendance" id="menu_open_view_attendance" parent="menu_hr_time_tracking" groups="base.group_hr_manager,base.group_hr_user,base.group_hr_attendance,base.group_system,base.group_user" sequence="3"/>

        <record id="edit_attendance_reason" model="ir.ui.view">
            <field name="name">hr.action.reason.form</field>
            <field name="model">hr.action.reason</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Define attendance reason">
                    <field colspan="4" name="name"  />
                    <field name="action_type" />
                </form>
            </field>
        </record>

        <record id="view_attendance_reason" model="ir.ui.view">
            <field name="name">hr.action.reason.tree</field>
            <field name="model">hr.action.reason</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Attendance reasons">
                    <field name="name"/>
                    <field name="action_type"/>
                </tree>
            </field>
        </record>

        <record id="open_view_attendance_reason" model="ir.actions.act_window">
            <field name="name">Attendance Reasons</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">hr.action.reason</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="view_attendance_reason"/>
        </record>

        <menuitem sequence="2" id="hr.menu_open_view_attendance_reason_new_config" parent="hr.menu_hr_configuration" name="Time Tracking" />
        <menuitem action="open_view_attendance_reason" id="menu_open_view_attendance_reason" parent="hr.menu_open_view_attendance_reason_new_config"/>

        <record id="hr_attendance_employee" model="ir.ui.view">
            <field name="name">hr.employee.form1</field>
            <field name="model">hr.employee</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="hr.view_employee_form"/>
            <field name="arch" type="xml">
                <field name="coach_id" position="after">
                    <group colspan="2">
                        <button name="attendance_action_change" states="present" string="Sign Out" type="object" icon="gtk-go-forward" context="{'type':'sign_out'}"/>
                        <button name="attendance_action_change" states="absent" string="Sign In" type="object" icon="gtk-go-back" context="{'type':'sign_in'}"/>
                    </group>
                    <field name="state"/>
                    <newline/>
                </field>
            </field>
        </record>

    </data>
</openerp>
