Reputation: 13342
In a model with a workflow, when you create a new record it starts a new workflow instance
. It will then transition between "activities" until it reaches a flow stop
, typically a cancel
or done
state.
What I'm experiencing in OpenERP 6.1, is that once a workflow instance
reaches the flow stop
, it's dead and you cannot perform more transitions on it.
But I would like to have a Reset to draft
button on a form that would allow a terminated workflow to be restarted. Is there a way to achieve this, say, through a Python call to a method of the Openerp workflow services?
Upvotes: 3
Views: 2118
Reputation: 5044
You can find an example at account payment module.
def set_to_draft(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {'state': 'draft'})
wf_service = netsvc.LocalService("workflow")
for id in ids:
wf_service.trg_create(uid, 'your.model.name', id, cr)
return True
Upvotes: 6
Reputation: 1579
You need to delete the workflow instance and recreate it. Check the method action_cancel_draft
in the purchase.order
model; It does exactly what you want to do.
Upvotes: 1