<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        
        
<!-- Contracts Button on Employee Form -->

        <record id="act_hr_employee_2_hr_contract" model="ir.actions.act_window">
            <field name="res_model">hr.contract</field>
            <field name="view_type">form</field>
            <field name="name">Contracts</field>
            <field name="view_mode">tree,form</field>
            <field name="context">{'search_default_employee_id': [active_id], 'default_employee_id': active_id}</field>
        </record>
        
        <menuitem id="next_id_56" name="Contract" parent="hr.menu_hr_configuration" sequence="30" groups="base.group_no_one"/>
        <record id="hr_hr_employee_view_form2" model="ir.ui.view">
            <field name="name">hr.hr.employee.view.form2</field>
            <field name="model">hr.employee</field>
            <field name="inherit_id" ref="hr.view_employee_form"/>
            <field name="arch" type="xml">
                <data>
                    <xpath expr="//div[@name='button_box']" position="inside">
                        <button name="%(act_hr_employee_2_hr_contract)d" string="Contracts" type="action" groups="base.group_hr_manager"/>
                    </xpath>
                    <xpath expr="//field[@name='coach_id']" position="after">
                        <field name="manager"/>
                    </xpath>
                    <xpath expr="//group[@name='active_group']" position="before">
                        <group string="Contract">
                            <field name="medic_exam" string="Medical Exam"/>
                            <field name="vehicle"/>
                            <field name="vehicle_distance"/>
                        </group>
                    </xpath>
                    <field name="marital" position="after">
                        <field name="children"/>
                    </field>
                    <field name="birthday" position="after">
                        <field name="place_of_birth"/>
                    </field>
                    <field name="bank_account_id" position="replace">
                        <field name="bank_account_id" context="{'display_partner':True}"/>
                    </field>
                </data>
            </field>
        </record>

        <record id="hr_contract_view_search" model="ir.ui.view">
            <field name="name">hr.contract.view.search</field>
            <field name="model">hr.contract</field>
            <field name="arch" type="xml">
                <search string="Search Contract">
                   <field name="name" string="Contracts"/>
                   <field name="date_start"/>
                   <field name="date_end"/>
                   <field name="working_hours"/>
                   <field name="employee_id"/>
                   <group expand="0" string="Group By...">
                       <filter string="Employee" icon="terp-personal" domain="[]" context="{'group_by':'employee_id'}"/>
                       <filter string="Working Schedule" icon="terp-go-week" domain="[]" context="{'group_by':'working_hours'}"/>
                       <filter string="Job" icon="terp-gtk-select-all" domain="[]" context="{'group_by':'job_id'}"/>
                       <filter string="Contract Type" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'type_id'}"/>
                   </group>
               </search>
            </field>
        </record>

        <record id="hr_contract_view_form" model="ir.ui.view">
            <field name="name">hr.contract.view.form</field>
            <field name="model">hr.contract</field>
            <field name="arch" type="xml">
                <form string="Contract" version="7.0">
                    <sheet>
                    <div class="oe_title">
                        <h1>
                            <field name="name" placeholder="Contract Reference"/>
                        </h1>
                    </div>
                    <group>
                        <group>
                            <field name="employee_id"/>
                            <field name="job_id"/>
                        </group>
                        <group>
                            <field name="type_id"/>
                        </group>
                    </group>
                    <notebook>
                        <page string="Information" name="information">
                            <group>
                                <group name="salary_and_advantages" string="Salary and Advantages">
                                    <field name="wage"/>
                                    <field name="advantages" nolabel="1" placeholder="Advantages..." colspan="2"/>
                                </group>
                                <group name="duration_group" string="Duration">
                                    <label for="trial_date_start" string="Trial Period Duration"/>
                                    <div>
                                        <field name="trial_date_start" class="oe_inline"/> - <field name="trial_date_end" class="oe_inline"/>
                                    </div>
                                    <label for="date_start" string="Duration"/>
                                    <div>
                                        <field name="date_start" class="oe_inline"/> - <field name="date_end" class="oe_inline"/>
                                    </div>
                                    <field name="working_hours"/>
                                </group>
                            </group>
                            <separator string="Notes"/>
                            <field name="notes"/>
                        </page>
                        <page string="Work Permit">
                            <group col="4">
                                <field name="visa_no"/>
                                <field name="permit_no"/>
                                <field name="visa_expire"/>
                            </group>
                        </page>
                    </notebook>
                    </sheet>
                </form>
            </field>
        </record>

        <record id="hr_contract_view_tree" model="ir.ui.view">
            <field name="name">hr.contract.view.tree</field>
            <field name="model">hr.contract</field>
            <field name="arch" type="xml">
                <tree string="Contracts">
                    <field name="name"/>
                    <field name="employee_id"/>
                    <field name="type_id"/>
                    <field name="job_id"/>
                    <field name="working_hours"/>
                    <field name="date_start"/>
                    <field name="date_end"/>
                    <field name="wage" invisible="1"/>
                </tree>
            </field>
        </record>

        <record id="action_hr_contract" model="ir.actions.act_window">
            <field name="name">Contracts</field>
            <field name="res_model">hr.contract</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="domain">[]</field>
            <field name="context">{'search_default_current':1}</field>
            <field name="search_view_id" ref="hr_contract_view_search"/>
        </record>

        <record id="hr_contract_type_view_form" model="ir.ui.view">
            <field name="name">hr.contract.type.view.form</field>
            <field name="model">hr.contract.type</field>
            <field name="arch" type="xml">
                <form string="Contract Type">
                    <field colspan="4" name="name"/>
                </form>
            </field>
        </record>

         <record id="hr_contract_type_view_tree" model="ir.ui.view">
            <field name="name">hr.contract.type.view.tree</field>
            <field name="model">hr.contract.type</field>
            <field name="arch" type="xml">
                <tree string="Contract Type">
                    <field colspan="4" name="name"/>
                </tree>
            </field>
        </record>

        <record id="hr_contract_type_view_search" model="ir.ui.view">
            <field name="name">hr.contract.type.view.search</field>
            <field name="model">hr.contract.type</field>
            <field name="arch" type="xml">
                <search string="Search Contract Type">
                    <field name="name" string="Contract Type"/>
               </search>
            </field>
        </record>

        <record id="action_hr_contract_type" model="ir.actions.act_window">
            <field name="name">Contract Types</field>
            <field name="res_model">hr.contract.type</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="search_view_id" ref="hr_contract_type_view_search"/>
        </record>

        <menuitem action="action_hr_contract_type" id="hr_menu_contract_type" parent="next_id_56" sequence="6" groups="base.group_no_one"/>
        <menuitem action="action_hr_contract" id="hr_menu_contract" parent="hr.menu_hr_main" name="Contracts" sequence="4" groups="base.group_hr_manager"/>

    </data>
</openerp>
