python 2.7 - OpenERP - How to change end of the workflow? -
i need add new " approval" node end of existing workflow , make end. please please me that
the workflow new node , 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> <!-- node 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 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 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> <!-- first transition 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> <!-- second transition 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 , 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 , 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 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>
add : true
in last_validated activity added in refused
Comments
Post a Comment