Odoo Help


Need help with workflows

Arjun Khode
on 6/2/15, 8:51 AM 711 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

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


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