Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Need help with workflows

Arjun Khode
on 6/2/15, 8:51 AM 305 views

Hi, I'm new to workflows.

I'm trying to understand how to program workflows but can't find a reliable source for practical examples online. (I've read the documentation and theory about workflows)

Can someone show me how to create a simple workflow so I could understand how it works?

Ankit Gauri
On 6/3/15, 9:10 AM

Hello Arjun 

1)first create seperate .xml file 

then put this code put your model name in the place of academic.session 

<?xml version="1.0"?>



<record model="workflow" id="wkf_academy">

<field name="name">academy.wkf</field>

<field name="osv">academic.session</field>

<field name="on_create">True</field>


<record model="workflow.activity" id="act_draft">

<field name="wkf_id" ref="wkf_academy" />

<field name="flow_start">True</field>

<field name="name">draft</field>

<field name="kind">function</field>

<field name="action">write({'state': 'draft'})</field>


<record model="workflow.activity" id="act_confirmed">

<field name="wkf_id" ref="wkf_academy" />

<field name="name">confirmed</field>

<field name="kind">function</field>

<field name="action">session_confirmed()</field>


<record model="workflow.activity" id="act_done">

<field name="wkf_id" ref="wkf_academy"/>

<field name="name">done</field>

<field name="kind">function</field>

<field name="action">session_done()</field>


<record model="workflow.transition" id="t1">

<field name="act_from" ref="act_draft"/>

<field name="act_to" ref="act_confirmed"/>

<field name="signal">session_confirmed</field>


<record model="workflow.transition" id="t2">

<field name="act_from" ref="act_confirmed"/>

<field name="act_to" ref="act_draft" />

<field name="signal">session_draft</field>


<record model="workflow.transition" id="t3">

<field name="act_from" ref="act_confirmed"/>

<field name="act_to" ref="act_done" />

<field name="signal">session_done</field>


<record model="workflow.transition" id="t4">

<field name="act_from" ref="act_done"/>

<field name="act_to" ref="act_draft" />

<field name="signal">session_draft</field>

<field name="flow_stop">True</field>




2) then put the following method inside  .py file in particular model that name you mention like i put my method inside academic.session model in .py file

def session_draft(self, cr, uid, ids,context=None):

self.write(cr, uid, ids, { 'state' : 'draft'},context=context)

return True

def session_confirmed(self, cr, uid, ids,context=None):

self.write(cr, uid, ids, { 'state' : 'confirmed'},context=context)

return True

def session_done(self, cr, uid, ids,context=None):

self.write(cr, uid, ids, { 'state' : 'done' },context=context)

return True

3)try to print workflow

Thank You

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 6/2/15, 8:51 AM
Seen: 305 times
Last updated: 6/3/15, 9:10 AM