<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <!-- Root Menus -->
        <menuitem id="menu_hr_root_payroll" parent="hr.menu_hr_root" name="Payroll" sequence="9"/>
        <menuitem id="payroll_configure" parent="hr.menu_hr_configuration" name="Payroll"/>
        <menuitem id="menu_hr_payroll_reporting" parent="hr.menu_hr_reporting" name="Payroll" groups="base.group_hr_manager"/>

        <!-- Employee View -->
        <record id="hr_contract.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="/form/notebook/page[@string='Personal Information']" position="after">
                    <page string="Miscellaneous" groups="base.group_hr_user">
                        <group colspan="2" col="2">
                            <separator string="Personal Info" colspan="2"/>
                            <field name="bank_account_id" context="{'display_partner':True, 'partner_id':partner_id}"/>
                            <field name="place_of_birth"/>
                            <field name="children"/>
                            <!-- <field name="basic" invisible="0"/> -->
                        </group>
                        <group colspan="2" col="2">
                            <separator string="Job Info" colspan="2"/>
                            <field name="manager" select="1"/>
                            <field name="vehicle" select="1"/>
                            <field name="vehicle_distance" select="1"/>
                            <field name="medic_exam" select="1" string="Medical Examination"/>
                        </group>
                    </page>
                </xpath>
            </data>
            </field>
        </record>
        <!-- End Employee View -->

        <!-- Contract View -->
        <record id="hr_contract_form_inherit" model="ir.ui.view">
            <field name="name">hr.contract.view.form.inherit</field>
            <field name="model">hr.contract</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
            <field name="arch" type="xml">
            <data>
                <xpath expr="/form/notebook/page/group/separator[@name='advantages']" position="before">
                    <separator string="Payslip Info" colspan="2"/>
                    <field name="struct_id" required="1"/>
                </xpath>
                 <xpath expr="/form/notebook/page/group/field[@name='working_hours']" position="after">
                    <field name="schedule_pay"/>
                </xpath>
            </data>
            </field>
        </record>

        <!-- End Contract View-->

        <!-- Salary structure -->
        <record id="view_hr_employee_grade_tree" model="ir.ui.view">
            <field name="name">hr.payroll.structure.tree</field>
            <field name="model">hr.payroll.structure</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Employee Function">
                    <field name="name"/>
                    <field name="code"/>
                    <field name="rule_ids"/>
                    <field name="company_id" groups="base.group_multi_company" widget="selection"/>
                </tree>
            </field>
        </record>

        <record id="view_hr_payroll_structure_filter" model="ir.ui.view">
            <field name="name">hr.payroll.structure.select</field>
            <field name="model">hr.payroll.structure</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Payroll Structures">
                    <group col="8" colspan="4">
                        <field name="name"/>
                        <field name="code"/>
                    </group>
                    <newline/>
                </search>
            </field>
        </record>

        <record id="view_hr_employee_grade_form" model="ir.ui.view">
            <field name="name">hr.payroll.structure.form</field>
            <field name="model">hr.payroll.structure</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Employee Function">
                    <group col="6" colspan="6">
                        <field name="name" select="1"/>
                        <field name="code" select="1"/>
                        <field name="company_id" groups="base.group_multi_company" widget="selection"/>
                        <field name="parent_id"/>
                    </group>
                    <notebook colspan="4">
                         <page string="Salary Rules">
                           <field colspan="4" name="rule_ids" nolabel="1" domain="[('parent_rule_id','=',False)]">
                             <tree>
                                <field name="name"/>
                                <field name="code"/>
                                <field name="category_id"/>
                                <field name="sequence" groups="base.group_extended" invisible="1"/>
                                <field name="register_id"/>
                             </tree>
                          </field>
                         </page>
                    </notebook>
                </form>
            </field>
        </record>

        <record id="action_view_hr_employee_grade_form" model="ir.actions.act_window">
            <field name="name">Salary Structures</field>
            <field name="res_model">hr.payroll.structure</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="view_hr_employee_grade_tree"/>
        </record>
        <menuitem
            id="menu_hr_employee_function"
            action="action_view_hr_employee_grade_form"
            parent="payroll_configure"
            sequence="1"
        />
        <!-- End Salary structure -->

        <!-- Payslip Line -->
        <record id="view_hr_payslip_line_tree" model="ir.ui.view">
            <field name="name">hr.payslip.line.tree</field>
            <field name="model">hr.payslip.line</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Salary Structure" editable="bottom" colors="blue:total == 0">
                    <field name="category_id"/>
                    <field name="employee_id" invisible="1"/>
                    <field name="sequence" groups="base.group_extended"/>
                    <field name="name"/>
                    <field name="code"/>
                    <field name="quantity" string="Quantity/Rate"/>
                    <field name="amount"/>
                    <field name="total"/>
                    <field name="amount_select" invisible="1"/>
                    <field name="register_id" invisible="1"/>
                </tree>
            </field>
        </record>
        <record id="view_hr_payslip_line_form" model="ir.ui.view">
            <field name="name">hr.payslip.line.form</field>
            <field name="model">hr.payslip.line</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Payslip Line">
                    <group col="6" colspan="4">
                        <field name="name" colspan="4" select="1"/>
                        <field name="code" select="1"/>
                        <field name="slip_id" select="1"/>
                        <field name="employee_id"/>
                    </group>
                    <group col="2" colspan="2">
                        <separator colspan="4" string="Calculations"/>
                        <field name="category_id"/>
                        <field name="amount_select"/>
                        <field name="amount_fix"  attrs="{'readonly':[('amount_select','&lt;&gt;','fix')]}"/>
                        <field name="amount_percentage"  attrs="{'readonly':[('amount_select','&lt;&gt;','percentage')]}"/>
                        <field name="sequence" groups="base.group_extended"/>
                    </group>
                    <notebook colspan="4">
                        <page string="Description">
                            <separator colspan="4" string="Description"/>
                            <field name="note" colspan="4" nolabel="1"/>
                        </page>
                    </notebook>
                </form>
            </field>
        </record>

        <record id="view_hr_payslip_line_filter" model="ir.ui.view">
            <field name="name">hr.payslip.line.select</field>
            <field name="model">hr.payslip.line</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Payslip Lines">
                    <group col="8" colspan="4">
                        <field name="name"/>
                        <field name="code"/>
                        <field name="slip_id"/>
                        <field name="amount_select"/>
                    </group>
                    <newline/>
                    <group col="8" colspan="4" expand="0" string="Group By...">
                        <filter string="Salary Rule Category" icon="terp-camera_test" name="category_id" context="{'group_by':'category_id'}"/>
                        <filter string="Contribution Register" name="register_id" icon="terp-folder-yellow" context="{'group_by':'register_id'}"/>
                        <separator orientation="vertical"/>
                        <filter string="Amount Type" name="amount_select" icon="terp-stock_symbol-selection" context="{'group_by':'amount_select'}"/>
                        <separator orientation="vertical"/>
                        <filter string="Employees" name="employee_id" icon="terp-personal" context="{'group_by':'employee_id'}"/>
                    </group>
                </search>
            </field>
        </record>


        <!-- payslip -->

        <record id="view_hr_payslip_tree" model="ir.ui.view">
            <field name="name">hr.payslip.tree</field>
            <field name="model">hr.payslip</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree colors="blue:state in ('confirm','hr_check','accont_check');black:state in ('new');gray:state in('cancel')" string="Payslips">
                    <field name="number"/>
                    <field name="employee_id"/>
                    <field name="name"/>
                    <field name="date_from"/>
                    <field name="date_to"/>
                    <field name="state"/>
                    <field name="company_id" groups="base.group_multi_company" widget="selection"/>
                    <field name="payslip_run_id" invisible="1"/>
                </tree>
            </field>
        </record>

        <record id="view_hr_payslip_form" model="ir.ui.view">
            <field name="name">hr.payslip.form</field>
            <field name="model">hr.payslip</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Payslip">
                    <group col="6" colspan="4">
                        <field name="employee_id" on_change="onchange_employee_id(date_from, date_to, employee_id, contract_id)"/>
                        <field name="number"/>
                        <field name="date_from"/>
                        <field name="contract_id" groups="base.group_extended" domain="[('employee_id','=',employee_id)]" on_change="onchange_contract_id(date_from, date_to, employee_id, contract_id)"/>
                        <field name="struct_id" groups="base.group_extended" attrs="{'required':[('contract_id','&lt;&gt;',False)]}"/>
                        <field name="date_to"/>
                        <field name="name" colspan="4"/>
                        <field name="credit_note"/>
                    </group>
                    <notebook colspan="4">
                        <page string="Salary Computation" >
                            <field name="line_ids" colspan="4" nolabel="1">
                                <tree string="Salary Structure" editable="bottom" colors="blue:total == 0">
                                    <field name="name"/>
                                    <field name="code"/>
                                    <field name="category_id"/>
                                    <field name="sequence" invisible="1"/>
                                    <field name="quantity" string="Quantity/Rate"/>
                                    <field name="amount"/>
                                    <field name="total"/>
                                </tree>
                                <form string="Payslip Line">
                                    <group>
                                        <field name="name" select="1"/>
                                        <field name="code" select="1"/>
                                        <field name="category_id"/>
                                        <field name="sequence" groups="base.group_extended"/>
                                        <field name="quantity" string="Quantity/Rate"/>
                                        <field name="amount"/>
                                        <field name="total"/>
                                        <field name="salary_rule_id" groups="base.group_extended"/>
                                    </group>
                                </form>
                            </field>
                        </page>
                        <page string="Details By Salary Rule Category">
                            <field name="details_by_salary_rule_category" context="{'group_by':'category_id'}" domain="[('appears_on_payslip', '=', True)]" nolabel="1">
                                <tree string="Payslip Lines" colors="blue:total == 0">
                                    <field name="category_id"/>
                                    <field name="name"/>
                                    <field name="code"/>
                                    <field name="total"/>
                                </tree>
                            </field>
                       </page>

                       <page string="Worked Days &amp; Inputs">
                            <field name="worked_days_line_ids" colspan="4" nolabel="1">
                                <tree string="Worked Days" editable="bottom">
                                    <field name="name"/>
                                    <field name="code"/>
                                    <field name="number_of_days" sum="Total Working Days"/>
                                    <field name="number_of_hours"/>
                                    <field name="contract_id" groups="base.group_extended"/>
                                    <field name="sequence" invisible="True"/>
                                </tree>
                                <form string="Worked Day">
                                    <group>
                                        <field name="name" select="1"/>
                                        <field name="code" select="1"/>
                                        <field name="payslip_id"/>
                                        <field name="sequence" groups="base.group_extended"/>
                                        <field name="number_of_days"/>
                                        <field name="number_of_hours"/>
                                        <field name="contract_id" groups="base.group_extended"/>
                                    </group>
                                </form>
                            </field>
                            <field name="input_line_ids" colspan="4" nolabel="1">
                                <tree string="Input Data" editable="bottom">
                                    <field name="name"/>
                                    <field name="code"/>
                                    <field name="amount"/>
                                    <field name="contract_id" groups="base.group_extended"/>
                                    <field name="sequence" invisible="True"/>
                                </tree>
                                <form string="Payslip Line">
                                    <group>
                                        <field name="name" select="1"/>
                                        <field name="code" select="1"/>
                                        <field name="payslip_id"/>
                                        <field name="sequence" groups="base.group_extended"/>
                                        <field name="amount"/>
                                        <field name="contract_id" groups="base.group_extended"/>
                                    </group>
                                </form>
                            </field>
                       </page>

                       <page string="Other Information">
                            <separator colspan="4" string="Other Information"/>
                            <group col="5" colspan="2">
                                <field name="company_id" groups="base.group_multi_company" widget="selection"/>
                                <field name="payslip_run_id" domain="[('state','=','draft')]"/>
                                <field name="paid" readonly="1"/>
                            </group>
                            <newline/>
                            <separator colspan="4" string="Notes"/>
                            <field name="note" colspan="4" nolabel="1"/>
                       </page>

                    </notebook>
                    <group col="10" colspan="4">
                        <field name="state"/>
                        <button string="Cancel" icon="terp-dialog-close" name="cancel_sheet" states="draft,hr_check,confirm,verify"/>
                        <button string="Compute Sheet" icon="terp-stock_format-scientific" name="compute_sheet" type="object" states="draft"/>
                        <button string="Set to Draft" icon="terp-stock_effects-object-colorize" name="draft" states="cancel"/>
                        <button string="Refund" icon="gtk-execute" name="refund_sheet" states="confirm,done" type='object'/>
                        <button string="Confirm" icon="terp-camera_test" name="hr_verify_sheet" states="draft"/>
                    </group>
                </form>
            </field>
        </record>

        <record id="view_hr_payslip_filter" model="ir.ui.view">
            <field name="name">hr.payslip.select</field>
            <field name="model">hr.payslip</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Payslips">
                    <group col="8" colspan="4">
                        <filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Slip"/>
                        <filter icon="terp-camera_test" string="Done" domain="[('state','=','done')]" help="Done Slip"/>
                        <separator orientation="vertical"/>
                        <field name="number"/>
                        <field name="employee_id"/>
                        <field name="name"/>
                        <field name="date_from"/>
                        <field name="payslip_run_id"/>
                    </group>
                    <newline/>
                    <group col="8" colspan="4" expand="0" string="Group By...">
                        <filter string="Employees" icon="terp-personal" name="employee_id" context="{'group_by':'employee_id'}"/>
                        <separator orientation="vertical"/>
                        <filter string="PaySlip Run" name="payslip_run_id" icon="terp-folder-orange" context="{'group_by':'payslip_run_id'}"/>
                        <separator orientation="vertical" groups="base.group_multi_company"/>
                        <filter string="Companies" name="company_id" groups="base.group_multi_company" icon="terp-go-home" context="{'group_by':'company_id'}"/>
                        <separator orientation="vertical"/>
                        <filter string="States" name="state" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
                    </group>
                </search>
            </field>
        </record>
        <record id="action_view_hr_payslip_form" model="ir.actions.act_window">
            <field name="name">Employee Payslips</field>
            <field name="res_model">hr.payslip</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="view_hr_payslip_tree"/>
            <field name="search_view_id" ref="view_hr_payslip_filter"/>
        </record>
        <menuitem action="action_view_hr_payslip_form" id="menu_department_tree" parent="menu_hr_root_payroll"/>

        <!-- Salary Category-->
        <record id="hr_salary_rule_category_form" model="ir.ui.view">
            <field name="name">hr.salary.rule.category.form</field>
            <field name="model">hr.salary.rule.category</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Salary Categories">
                    <group col="3" colspan="6">
                        <field name="name" select="1"/>
                        <field name="code" select="1"/>
                        <field name="parent_id" select="1"/>
                    </group>
                    <separator colspan="4" string="Notes"/>
                        <field name="note" colspan="4" nolabel="1"/>
                </form>
            </field>
        </record>

        <record id="hr_salary_rule_category_tree" model="ir.ui.view">
            <field name="name">hr.salary.rule.category.tree</field>
            <field name="model">hr.salary.rule.category</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Salary Rule Categories">
                    <field name="name"/>
                    <field name="code"/>
                    <field name="parent_id" invisible="1"/>
                </tree>
            </field>
        </record>

        <record id="view_hr_salary_rule_category_filter" model="ir.ui.view">
            <field name="name">hr.salary.rule.category.select</field>
            <field name="model">hr.salary.rule.category</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Salary Rule Categories">
                    <field name="name" select="1"/>
                     <field name="code" select="1"/>
               </search>
            </field>
        </record>

        <record id="action_hr_salary_rule_category" model="ir.actions.act_window">
            <field name="name">Salary Rule Categories</field>
            <field name="res_model">hr.salary.rule.category</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="hr_salary_rule_category_tree"/>
           <field name="search_view_id" ref="view_hr_salary_rule_category_filter"/>
        </record>
        <menuitem
            id="menu_hr_salary_rule_category"
            action="action_hr_salary_rule_category"
            parent="payroll_configure"
            sequence="11"
        />

        <!--
        Contribution Register
        -->
        <record id="hr_contribution_register_tree" model="ir.ui.view">
            <field name="name">hr.contribution.register.tree</field>
            <field name="model">hr.contribution.register</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Contribution Registers">
                    <field name="name" select="1"/>
                    <field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/>
                </tree>
            </field>
        </record>
        <record id="hr_contribution_register_filter" model="ir.ui.view">
            <field name="name">hr.contribution.register.search</field>
            <field name="model">hr.contribution.register</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Contribution Registers">
                    <field name="name"/>
                    <field name="company_id" groups="base.group_multi_company" widget="selection"/>
                </search>
            </field>
        </record>
        <record id="hr_contribution_register_form" model="ir.ui.view">
            <field name="name">hr.contribution.register.form</field>
            <field name="model">hr.contribution.register</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Contribution">
                    <field name="name" select="1"/>
                    <field name="company_id" select="1" groups="base.group_multi_company" widget="selection"/>
                    <notebook colspan="4">
                         <page string="Description">
                            <separator colspan="4" string="Description"/>
                            <field name="note" colspan="4" nolabel="1"/>
                        </page>
                    </notebook>
                </form>
            </field>
        </record>
        <record id="action_contribution_register_form" model="ir.actions.act_window">
            <field name="name">Contribution Registers</field>
            <field name="res_model">hr.contribution.register</field>
            <field name="view_type">form</field>
            <field name="help">A contribution register is a third party involved in the salary payment of the employees. It can be the social security, the estate or anyone that collect or inject money on payslips.</field>
            <field name="view_id" ref="hr_contribution_register_tree"/>
        </record>
        <menuitem
            id="menu_action_hr_contribution_register_form"
            action="action_contribution_register_form"
            parent="payroll_configure"
            sequence="14"
        />

        <!-- Salary Rules -->

        <record id="hr_salary_rule_tree" model="ir.ui.view">
            <field name="name">hr.salary.rule.tree</field>
            <field name="model">hr.salary.rule</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Salary Rules">
                    <field name="name"/>
                    <field name="code"/>
                    <field name="category_id"/>
                    <field name="sequence" groups="base.group_extended" invisible="1"/>
                    <field name="register_id"/>
                </tree>
            </field>
        </record>
        <record id="hr_salary_rule_form" model="ir.ui.view">
            <field name="name">hr.salary.rule.form</field>
            <field name="model">hr.salary.rule</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Salary Rules">
                    <group col="6" colspan="6">
                       <field name="name"/>
                       <field name="code" select="1"/>
                       <field name="category_id"/>
                       <field name="sequence" />
                       <field name="active"/>
                       <field name="appears_on_payslip"/>
                       <field name="company_id" widget="selection" groups="base.group_multi_company"/>
                    </group>
                    <notebook colspan="6">
                        <page string="General">
                                <group col="4" colspan="6">
                                    <separator colspan="4" string="Conditions"/>
                                    <field name="condition_select"/><newline/>
                                    <field name="condition_python" attrs="{'invisible':[('condition_select','&lt;&gt;','python')], 'required': [('condition_select','=','python')]}" colspan="4"/> <newline/>
                                    <field name="condition_range" attrs="{'invisible':[('condition_select','&lt;&gt;','range')], 'required':[('condition_select','=','range')]}"/><newline/>
                                    <field name="condition_range_min" colspan="2" attrs="{'invisible':[('condition_select','&lt;&gt;','range')], 'required':[('condition_select','=','range')]}"/><newline/>
                                    <field name="condition_range_max" colspan="2" attrs="{'invisible':[('condition_select','&lt;&gt;','range')], 'required':[('condition_select','=','range')]}"/><newline/>
                                    <separator colspan="4" string="Computation"/>
                                    <field name="amount_select"/><newline/>
                                    <field name="amount_percentage_base" attrs="{'invisible':[('amount_select','&lt;&gt;','percentage')], 'required': [('amount_select','=','percentage')]}"/><newline/>
                                    <field name="quantity" attrs="{'invisible':[('amount_select','=','code')], 'required':[('amount_select','!=','code')]}"/><newline/>
                                    <field name="amount_fix"  attrs="{'invisible':[('amount_select','&lt;&gt;','fix')], 'required':[('amount_select','=','fix')]}"/><newline/>
                                    <field name="amount_percentage" attrs="{'invisible':[('amount_select','&lt;&gt;','percentage')], 'required':[('amount_select','=','percentage')]}"/>
                                    <field colspan="4" name="amount_python_compute" attrs="{'invisible':[('amount_select','&lt;&gt;','code')], 'required':[('amount_select','=','code')]}"/>
                                    <separator colspan="4" string="Company contribution"/>
                                    <field name="register_id"/>
                                </group>
                        </page>
                        <page string="Child Rules">
                           <field name="parent_rule_id"/>
                           <separator colspan="4" string="Children definition"/>
                           <field colspan="4" name="child_ids" nolabel="1"/>
                        </page>
                           <page string="Inputs">
                                <field name="input_ids" colspan="4" nolabel="1" mode="tree, form">
                                    <tree string="Input Data" editable="bottom">
                                        <field name="name"/>
                                        <field name="code"/>
                                    </tree>
                                </field>
                           </page>
                        <page string="Description">
                            <field name="note" colspan="4" nolabel="1"/>
                        </page>
                    </notebook>
                </form>
            </field>
        </record>

        <record id="view_hr_rule_filter" model="ir.ui.view">
            <field name="name">hr.salary.rule.select</field>
            <field name="model">hr.salary.rule</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Salary Rule">
                    <group col="8" colspan="4">
                        <field name="name"/>
                        <field name="code" select="1"/>
                        <field name="category_id"/>
                        <field name="condition_range_min"/>
                    </group>
                    <newline/>
                    <group col="8" colspan="4" expand="0" string="Group By...">
                        <filter string="Category" icon="terp-folder-yellow" name="head" context="{'group_by':'category_id'}"/>
                    </group>
                </search>
            </field>
        </record>

        <record id="action_salary_rule_form" model="ir.actions.act_window">
            <field name="name">Salary Rules</field>
            <field name="res_model">hr.salary.rule</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="hr_salary_rule_tree"/>
            <field name="domain">[('parent_rule_id','=',False)]</field>
            <field name="search_view_id" ref="view_hr_rule_filter"/>
        </record>

        <menuitem id="menu_action_hr_salary_rule_form" action="action_salary_rule_form" parent="payroll_configure" sequence="12"/>


        <!-- payslip runs -->

        <record id="hr_payslip_run_filter" model="ir.ui.view">
            <field name="name">hr.payslip.run.search</field>
            <field name="model">hr.payslip.run</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Payslip Runs">
                    <filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft runs"/>
                    <filter icon="terp-camera_test" string="Done" domain="[('state','=','done')]" help="Done runs"/>
                    <separator orientation="vertical"/>
                    <field name="name"/>
                    <field name="date_start"/>
                    <field name="date_end"/>
                </search>
            </field>
        </record>

        <record id="hr_payslip_run_tree" model="ir.ui.view">
            <field name="name">hr.payslip.run.tree</field>
            <field name="model">hr.payslip.run</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Payslips Run">
                    <field name="name"/>
                    <field name="date_start"/>
                    <field name="date_end"/>
                    <field name="credit_note"/>
                </tree>
            </field>
        </record>

        <record id="hr_payslip_run_form" model="ir.ui.view">
            <field name="name">hr.payslip.run.form</field>
            <field name="model">hr.payslip.run</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Payslips Run">
                    <group col="6" colspan="4">
                        <field name="name" colspan="4"/>
                        <field name="credit_note"/>
                        <field name="date_start"/>
                        <field name="date_end"/>
                    </group>
                    <notebook colspan="4">
                        <page string="Payslips">
                            <field name="slip_ids" colspan="4" nolabel="1"/>
                        </page>
                    </notebook>
                    <group col="6" colspan="4">
                        <field name="state"/>
                        <button name="%(action_hr_payslip_by_employees)d" type="action" states="draft" icon="gtk-execute" string="Generate Payslips" />
                        <button name="close_payslip_run" type="object" icon="terp-camera_test" string="Close" states="draft"/>
                        <button string="Set to Draft" icon="terp-stock_effects-object-colorize" name="draft_payslip_run" type="object" states="close"/>
                    </group>
                </form>
            </field>
        </record>

        <record id="action_hr_payslip_run_tree" model="ir.actions.act_window">
            <field name="name">Payslips Run</field>
            <field name="res_model">hr.payslip.run</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="hr_payslip_run_tree"/>
            <field name="search_view_id" ref="hr_payslip_run_filter"/>
        </record>
        <menuitem action="action_hr_payslip_run_tree" id="menu_hr_payslip_run" parent="menu_hr_root_payroll"/>

        <!--  Shortcuts -->

        <act_window name="Payslips"
            domain="[('employee_id', '=', active_id)]"
            context="{'search_default_employee_id': [active_id], 'default_employee_id': active_id}"
            res_model="hr.payslip"
            src_model="hr.employee"
            view_id ="view_hr_payslip_tree"
            id="act_hr_employee_payslip_list"
            groups="base.group_hr_manager"/>

        <act_window domain="[('slip_id', '=', active_id)]" context="{'search_default_register_id': 1}" id="act_payslip_lines" name="Payslip Lines" res_model="hr.payslip.line" src_model="hr.payslip"/>

    </data>
</openerp>

