A workflow needs to be inherited for number of reasons to meet one’s requirement.

Adding a new activity to existing workflow-

<record id=”activity_id” model=”workflow.activity”>
<field name=”wkf_id” ref=”module.workflow_id”/>
<field name=”name”>activity_name</field>
</record>

Example-

Here Approval activity has been added to sales workflow

<record id=”act_approval” model=”workflow.activity”>
<field name=”wkf_id” ref=”sale.wkf_sale”/>
<field name=”name”>approval</field>
<field name=”kind”>function</field>
<field name=”action”>action_approval()</field>
</record>

Modifying an activity of existing workflow-

<record id=”module.activity_id” model=”workflow.activity”>
<field name=”wkf_id” ref=”module.workflow_id”/>
<field name=”name”>activity_name</field>
</record>

Example-

act_ship activity of sales wokflow is modified to add one more function

<record id=”sale.act_ship” model=”workflow.activity”>
<field name=”wkf_id” ref=”sale.wkf_sale”/>
<field name=”name”>ship</field>
<field name=”kind”>function</field>
<field name=”action”>action_ship_create()
action_ship_new_funct()</field>
</record>

Adding/Modifying transitions in existing workflow-

<record id=”trans_id” model=”workflow.transition”>
<field name=”act_from” ref=”module.act_from_id”/>
<field name=”act_to” ref=”new_act_id”/>
</record>

Example-

Here, a new transition has been added from draft to approval.

<record id=”trans_act_draft_approval” model=”workflow.transition”>
<field name=”act_from” ref=”sale.act_draft”/>
<field name=”act_to” ref=”act_approval”/>
<field name=”signal”>confirm_approve</field>
</record>

For creating new workflow, my suggestion is to start with a simple flow with function defined at each activity. Then, test the flow by checking the right function is getting called. Once the flow is proper you can go ahead and add complex functionality. The reason for this approach is that OpenERP does not throw any exception in case of error.

Advertisements