# HG changeset patch
# Parent c72382bf0c5794135fa318f6ba59899b2277d8c5

Index: addons/openacademy/__openerp__.py
===================================================================
--- addons.orig/openacademy/__openerp__.py	2014-08-28 14:22:04.135015524 +0200
+++ addons/openacademy/__openerp__.py	2014-08-28 14:22:04.131015524 +0200
@@ -29,6 +29,7 @@
         'templates.xml',
         'views/openacademy.xml',
         'views/partner.xml',
+        'views/session_workflow.xml',
     ],
     # only loaded in demonstration mode
     'demo': [
Index: addons/openacademy/models.py
===================================================================
--- addons.orig/openacademy/models.py	2014-08-28 14:22:04.135015524 +0200
+++ addons/openacademy/models.py	2014-08-28 14:22:04.131015524 +0200
@@ -70,7 +70,7 @@
          ('draft', "Draft"),
          ('confirmed', "Confirmed"),
          ('done', "Done"),
-    ], default='draft')
+    ])
 
     @api.one
     def action_draft(self):
Index: addons/openacademy/views/openacademy.xml
===================================================================
--- addons.orig/openacademy/views/openacademy.xml	2014-08-28 14:22:04.135015524 +0200
+++ addons/openacademy/views/openacademy.xml	2014-08-28 14:22:04.131015524 +0200
@@ -97,13 +97,13 @@
             <field name="arch" type="xml">
                 <form string="Session Form">
                     <header>
-                        <button name="action_draft" type="object"
+                        <button name="draft" type="workflow"
                                 string="Reset to draft"
                                 states="confirmed,done"/>
-                        <button name="action_confirm" type="object"
+                        <button name="confirm" type="workflow"
                                 string="Confirm" states="draft"
                                 class="oe_highlight"/>
-                        <button name="action_done" type="object"
+                        <button name="done" type="workflow"
                                 string="Mark as done" states="confirmed"
                                 class="oe_highlight"/>
                         <field name="state" widget="statusbar"/>
Index: addons/openacademy/views/session_workflow.xml
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ addons/openacademy/views/session_workflow.xml	2014-08-28 14:22:04.131015524 +0200
@@ -0,0 +1,50 @@
+<openerp>
+    <data>
+        <record model="workflow" id="wkf_session">
+            <field name="name">OpenAcademy sessions workflow</field>
+            <field name="osv">openacademy.session</field>
+            <field name="on_create">True</field>
+        </record>
+
+        <record model="workflow.activity" id="draft">
+            <field name="name">Draft</field>
+            <field name="wkf_id" ref="wkf_session"/>
+            <field name="flow_start" eval="True"/>
+            <field name="kind">function</field>
+            <field name="action">action_draft()</field>
+        </record>
+        <record model="workflow.activity" id="confirmed">
+            <field name="name">Confirmed</field>
+            <field name="wkf_id" ref="wkf_session"/>
+            <field name="kind">function</field>
+            <field name="action">action_confirm()</field>
+        </record>
+        <record model="workflow.activity" id="done">
+            <field name="name">Done</field>
+            <field name="wkf_id" ref="wkf_session"/>
+            <field name="kind">function</field>
+            <field name="action">action_done()</field>
+        </record>
+
+        <record model="workflow.transition" id="session_draft_to_confirmed">
+            <field name="act_from" ref="draft"/>
+            <field name="act_to" ref="confirmed"/>
+            <field name="signal">confirm</field>
+        </record>
+        <record model="workflow.transition" id="session_confirmed_to_draft">
+            <field name="act_from" ref="confirmed"/>
+            <field name="act_to" ref="draft"/>
+            <field name="signal">draft</field>
+        </record>
+        <record model="workflow.transition" id="session_done_to_draft">
+            <field name="act_from" ref="done"/>
+            <field name="act_to" ref="draft"/>
+            <field name="signal">draft</field>
+        </record>
+        <record model="workflow.transition" id="session_confirmed_to_done">
+            <field name="act_from" ref="confirmed"/>
+            <field name="act_to" ref="done"/>
+            <field name="signal">done</field>
+        </record>
+    </data>
+</openerp>
