Openerp 工作流的流程返回
一个简单的审批工作流程,流程图如下:
普通流程是直线的,这个流程的难点在于增加了一个退回的节点,这就需要在流程设计时,有一个触发信号位于此流程之外。
代码如下:
流程节点定义:
<record model="workflow.activity" id="act_draft_setting"> <!-- draft --> <field name="wkf_id" ref="wkf_holidays_setting" /> <field name="flow_start">True</field> <field name="name">draft_setting</field> <!--<field name="action">button_submit()</field>--> </record> <!-- wait_modify--> <record model="workflow.activity" id="act_wait_modify_setting"> <field name="wkf_id" ref="wkf_holidays_setting" /> <field name="name">wait_modify_setting</field> <field name="kind">function</field> <field name="action">button_return()</field> </record> <record model="workflow.activity" id="act_wait_confirm_setting"> <!-- wait_confirm --> <field name="wkf_id" ref="wkf_holidays_setting" /> <field name="name">wait_confirm_setting</field> <field name="kind">function</field> <field name="action">button_confirm()</field> </record> <!-- validate--> <record model="workflow.activity" id="act_validate_setting"> <field name="wkf_id" ref="wkf_holidays_setting" /> <field name="name">validate_setting</field> <field name="kind">function</field> <field name="action">button_validate()</field> </record>
节点迁移定义:
<record model="workflow.transition" id="holiday_setting_draft2confirm"> <!-- 1. draft->wait_confirmed (no signal) --> <field name="act_from" ref="act_draft_setting" /> <field name="act_to" ref="act_wait_confirm_setting" /> </record> <record model="workflow.transition" id="holiday_setting_confirm2validate"> <!-- 2. wait_confirm->validate(validate signal)--> <field name="act_from" ref="act_wait_confirm_setting" /> <field name="act_to" ref="act_validate_setting" /> <field name="signal">validate_setting</field> <field name="group_id" ref="base.group_hr_user"/> </record> <!-- 2. wait_confirm->wait_modify(return signal)--> <record model="workflow.transition" id="holiday_setting_confirm2modify"> <field name="act_from" ref="act_wait_confirm_setting" /> <field name="act_to" ref="act_wait_modify_setting" /> <field name="signal">wait_modify_setting</field> <field name="group_id" ref="base.group_hr_user"/> </record> <!-- 2. wait_modify->wait_confirm(submit signal)--> <record model="workflow.transition" id="holiday_setting_modify2confirm"> <field name="act_from" ref="act_wait_modify_setting" /> <field name="act_to" ref="act_wait_confirm_setting" /> <field name="signal">button_submit</field> <!--注意这个信号button_submit不是任何一个流程节点的动作--> <field name="group_id" ref="base.group_hr_user"/> </record>
xml文件中的button定义:
<button string="审核" name="validate_setting" states="wait_confirm" type="workflow" groups="base.group_hr_user" class="oe_highlight"/> <button string="退回" name="wait_modify_setting" states="wait_confirm" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
<!--注意button_submit的type不是workflow-->
<button string="提交" name="button_submit" states="wait_modify" groups="base.group_hr_user" class="oe_highlight"/>
剩下的就是在python中定义每个button的代码即可。