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

    <!-- Roles definition -->

    <record model="res.roles" id="HR_holidays">
        <field name="name">Leaves Manager</field>
    </record>

    <!-- Workflow definition -->

    <record model="workflow" id="wkf_holidays">
        <field name="name">hr.wkf.holidays</field>
        <field name="osv">hr.holidays</field>
        <field name="on_create">True</field>
    </record>

    <record model="workflow.activity" id="act_draft">
        <field name="wkf_id" ref="wkf_holidays" />
        <field name="flow_start">True</field>
        <field name="name">draft</field>
    </record>

    <record model="workflow.activity" id="act_confirm">
        <field name="wkf_id" ref="wkf_holidays" />
        <field name="name">confirm</field>
        <field name="kind">function</field>
        <field name="action">holidays_confirm()</field>
        <field name="split_mode">OR</field>
    </record>

    <record model="workflow.activity" id="act_validate">
        <field name="wkf_id" ref="wkf_holidays" />
        <field name="name">validate</field>
        <field name="kind">function</field>
        <field name="action">holidays_validate()</field>
    </record>

    <record model="workflow.activity" id="act_validate1">
        <field name="wkf_id" ref="wkf_holidays" />
        <field name="name">second_validate</field>
        <field name="kind">function</field>
        <field name="action">holidays_validate2()</field>
    </record>


    <record model="workflow.activity" id="act_refuse">
        <field name="wkf_id" ref="wkf_holidays" />
        <field name="name">refuse</field>
        <field name="kind">function</field>
        <field name="action">holidays_refuse()</field>

    </record>

    <record model="workflow.activity" id="act_cancel">
        <field name="wkf_id" ref="wkf_holidays" />
        <field name="name">cancel</field>
        <field name="flow_stop">True</field>
        <field name="kind">stopall</field>
        <field name="action">holidays_cancel()</field>
        <field name="join_mode">XOR</field>
    </record>

    <!--
        workflow transition
    -->

    <record model="workflow.transition" id="t1">
        <field name="act_from" ref="act_draft" />
        <field name="act_to" ref="act_confirm" />
        <field name="signal">confirm</field>
    </record>

    <record model="workflow.transition" id="t2">
        <field name="act_from" ref="act_confirm" />
        <field name="act_to" ref="act_validate" />
        <field name="signal">validate</field>
        <field name="condition">(holiday_status_id.double_validation == False)</field>
        <field name="role_id" ref="HR_holidays"/>
    </record>

    <record model="workflow.transition" id="t3">
        <field name="act_from" ref="act_confirm" />
        <field name="act_to" ref="act_refuse" />
        <field name="signal">refuse</field>
        <field name="role_id" ref="HR_holidays"/>
    </record>

    <record model="workflow.transition" id="t4">
        <field name="act_from" ref="act_validate" />
        <field name="act_to" ref="act_cancel" />
        <field name="signal">cancel</field>
        <field name="role_id" ref="HR_holidays"/>
    </record>

    <record model="workflow.transition" id="t5">
        <field name="act_from" ref="act_refuse" />
        <field name="act_to" ref="act_cancel" />
        <field name="signal">cancel</field>
        <field name="role_id" ref="HR_holidays"/>
    </record>

    <record model="workflow.transition" id="t7">
        <field name="act_from" ref="act_cancel" />
        <field name="act_to" ref="act_draft" />
        <field name="signal">set_to_draft</field>
    </record>

    <record model="workflow.transition" id="t8">
        <field name="act_from" ref="act_validate1" />
        <field name="act_to" ref="act_validate" />
        <field name="signal">second_validate</field>
    </record>

    <record model="workflow.transition" id="t10">
        <field name="act_from" ref="act_validate1" />
        <field name="act_to" ref="act_refuse" />
        <field name="signal">refuse</field>
    </record>

    <record model="workflow.transition" id="t11">
        <field name="act_from" ref="act_confirm" />
        <field name="act_to" ref="act_validate1" />
        <field name="condition">(holiday_status_id.double_validation == True)</field>
        <field name="signal">validate</field>
        <field name="role_id" ref="HR_holidays"/>
    </record>

</data>
</openerp>
