Skip to Content
Menu
This question has been flagged

I need to add another new " Approval" node to the end of the existing workflow and make it end. PLEASE PLEASE help me with that

The workflow with the new Node and Transition

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

    <!-- Workflow definition 
        1. draft->submitted (no signal)
        2. submitted->accepted (validate signal) if not double_validation
        2. submitted -> first_accepted (validate signal) if double_validation
        2. submitted->refused (refuse signal)
        3. accepted->refused (refuse signal)
        4. first_accepted -> accepted (second_validate  signal)
        4. first_accepted -> refused (refuse signal)
        5. accepted -> last_accepted (last_validate signal)
        5. last_accepted -> refused (refuse signal)
    -->

    <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"> <!-- 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"> <!-- submitted -->
        <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"> <!-- accepted -->
        <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"> <!-- first_accepted -->
        <field name="wkf_id" ref="wkf_holidays" />
        <field name="name">first_validate</field>
        <field name="kind">function</field>
        <field name="action">holidays_first_validate()</field>
        <field name="split_mode">OR</field>
    </record>

<!-- The Node I have added -->
 <record model="workflow.activity" id="act_validate2"> <!-- leave_confirmed -->
        <field name="wkf_id" ref="wkf_holidays" />
        <field name="name">last_validate</field>
        <field name="kind">function</field>
        <field name="action">holidays_second_validate()</field>
        <field name="split_mode">OR</field>
    </record>


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

    <!--
        workflow transition
    -->

    <record model="workflow.transition" id="holiday_draft2confirm"> <!-- 1. draft->submitted (no signal) -->
        <field name="act_from" ref="act_draft" />
        <field name="act_to" ref="act_confirm" />
    </record>

    <record model="workflow.transition" id="holiday_confirm2validate"> <!-- 2. submitted->accepted (validate signal) if not double_validation-->
        <field name="act_from" ref="act_confirm" />
        <field name="act_to" ref="act_validate" />
        <field name="signal">validate</field>
        <field name="condition">not double_validation</field>
        <field name="group_id" ref="base.group_hr_user"/>
    </record>
<!-- belongs to kachal case - first trans -->
    <record model="workflow.transition" id="holiday_confirm2validate1"> <!-- 2. submitted -> first_accepted (validate signal) if double_validation-->
        <field name="act_from" ref="act_confirm" />
        <field name="act_to" ref="act_validate1" />
        <field name="signal">validate</field>
        <field name="condition">sub_flag</field>
        <field name="group_id" ref="base.group_hr_user"/>
    </record>


    <record model="workflow.transition" id="holiday_confirm2refuse"> <!-- 2. submitted->refused (refuse signal) -->
        <field name="act_from" ref="act_confirm" />
        <field name="act_to" ref="act_refuse" />
        <field name="signal">refuse</field>
        <field name="condition">True</field>
        <field name="group_id" ref="base.group_hr_user"/>
    </record>

    <record model="workflow.transition" id="holiday_validate2refuse"> <!-- 3. accepted->refused (refuse signal) -->
        <field name="act_from" ref="act_validate" />
        <field name="act_to" ref="act_refuse" />
        <field name="signal">refuse</field>
        <field name="condition">True</field>
        <field name="group_id" ref="base.group_hr_user"/>
    </record>

    <record model="workflow.transition" id="holiday_validate2refuse"> <!-- 3. accepted->refused (refuse signal) -->
        <field name="act_from" ref="act_validate" />
        <field name="act_to" ref="act_refuse" />
        <field name="signal">refuse</field>
        <field name="condition">True</field>
        <field name="group_id" ref="base.group_hr_user"/>
    </record>

<!-- belongs to kachal case - second trans -->
    <record model="workflow.transition" id="holiday_validate1_validate"> <!-- 4. first_accepted -> accepted (second_validate  signal) -->
        <field name="act_from" ref="act_validate1" />
        <field name="act_to" ref="act_validate2" />
        <field name="condition">True</field>
        <field name="signal">second_validate</field>
        <field name="group_id" ref="base.group_hr_user"/>
    </record>


    <record model="workflow.transition" id="holiday_validate1_refuse"> <!-- 4. first_accepted->refused (refuse signal) -->
        <field name="act_from" ref="act_validate1" />
        <field name="act_to" ref="act_refuse" />
        <field name="signal">refuse</field>
        <field name="condition">True</field>
        <field name="group_id" ref="base.group_hr_user"/>
    </record>

<!-- The first transition I have added -->
   <record model="workflow.transition" id="holiday_validate1_validate"> <!-- 5. last_accepted -> accepted (third_validate  signal) -->
        <field name="act_from" ref="act_validate2" />
        <field name="act_to" ref="act_validate" />
        <field name="condition">True</field>
        <field name="signal">last_validate</field>
        <field name="group_id" ref="base.group_hr_user"/>
    </record>

<!-- The second transition I have added -->
    <record model="workflow.transition" id="holiday_validate1_refuse"> <!-- 5. last_accepted->refused (refuse signal) -->
        <field name="act_from" ref="act_validate2" />
        <field name="act_to" ref="act_refuse" />
        <field name="signal">refuse</field>
        <field name="condition">True</field>
        <field name="group_id" ref="base.group_hr_user"/>
    </record>

</data>
</openerp>

The python file workflow call and relevant function

 'state': fields.selection([('draft', 'To Submit'), ('cancel', 'Cancelled'),('confirm', 'To Approve'), ('refuse', 'Refused'), ('validate1', 'Second Approval'), ('validate', 'Approved'), ('last_validate', 'Accepted')],


def holidays_last_validate(self, cr, uid, ids, context=None):
        self.check_holidays(cr, uid, ids, context=context)
        obj_emp = self.pool.get('hr.employee')
        ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)])
        manager = ids2 and ids2[0] or False
        self.holidays_first_validate_notificate(cr, uid, ids, context=context)
        return self.write(cr, uid, ids, {'state':'last_validate', 'manager_id': manager}

XML button call

<header>
                    <button string="Approve" name="validate" states="confirm" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
                    <button string="Validate" name="second_validate" states="validate1" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
                    <button string="Accepted" name="last_validate" states="last_validate" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
                    <button string="Refuse" name="refuse" states="confirm,validate1,last_validate,validate" type="workflow" groups="base.group_hr_user"/>
                    <button string="Reset to New" name="set_to_draft" states="refuse" type="object" groups="base.group_hr_user"/>
                    <field name="state" widget="statusbar" statusbar_visible="draft,confirm,validate" statusbar_colors='{"confirm":"blue","validate1":"blue","last_validate":"blue","refuse":"red"}'/>
                </header>


Avatar
Discard
Related Posts Replies Views Activity
1
Jul 16
2899
0
Jul 16
18
0
Nov 24
28
1
Jun 16
3170
3
Mar 16
2094