<?xml version="1.0"?>
<openerp>
  <data>
    <record model="workflow" id="wkf_pos">
      <field name="name">Pos workflow</field>
      <field name="osv">pos.order</field>
      <field name="on_create">True</field>
    </record>

<!--Activities-->

    <record model="workflow.activity" id="act_draft">
      <field name="wkf_id" ref="wkf_pos"/>
      <field name="flow_start">True</field>
      <field name="name">draft</field>
    </record>

    <record model="workflow.activity" id="act_paid">
      <field name="wkf_id" ref="wkf_pos"/>
      <field name="name">paid</field>
      <field name="action">action_paid()</field>
      <field name="kind">function</field>
    </record>

    <record model="workflow.activity" id="act_done">
      <field name="wkf_id" ref="wkf_pos"/>
      <field name="name">done</field>
      <field name="flow_stop">True</field>
      <field name="action">action_done()</field>
      <field name="kind">function</field>
    </record>

    <record model="workflow.activity" id="act_invoiced">
      <field name="wkf_id" ref="wkf_pos"/>
      <field name="name">invoiced</field>
      <field name="flow_stop">True</field>
      <field name="action">action_invoice_state()</field>
      <field name="kind">function</field>
    </record>

    <record model="workflow.activity" id="act_cancel">
      <field name="wkf_id" ref="wkf_pos"/>
      <field name="name">cancel</field>
      <field name="flow_stop">True</field>
      <field name="action">action_cancel()</field>
      <field name="kind">function</field>
    </record>


<!--Transitions-->

    <record model="workflow.transition" id="trans_draft_paid">
      <field name="act_from" ref="act_draft"/>
      <field name="act_to" ref="act_paid"/>
      <field name="condition">test_paid()</field>
      <field name="signal">paid</field>
    </record>

    <record model="workflow.transition" id="trans_paid_done">
        <field name="act_from" ref="act_paid"/>
        <field name="act_to" ref="act_done"/>
        <field name="signal">done</field>
    </record>

    <record model="workflow.transition" id="trans_paid_invoice">
      <field name="act_from" ref="act_paid"/>
      <field name="act_to" ref="act_invoiced"/>
      <field name="signal">invoice</field>
    </record>

    <record model="workflow.transition" id="trans_paid_cancel">
      <field name="act_from" ref="act_draft"/>
      <field name="act_to" ref="act_cancel"/>
      <field name="signal">cancel</field>
    </record>


  </data>

  <data>
    <record model="workflow" id="wkf_pos_session">
      <field name="name">POS Session Workflow</field>
      <field name="osv">pos.session</field>
      <field name="on_create">True</field>
    </record>

    <!-- Activities -->

    <record model="workflow.activity" id="act_start">
      <field name="wkf_id" ref="wkf_pos_session" />
      <field name="flow_start">True</field>
      <field name="name">start</field>
    </record>

    <record model="workflow.activity" id="act_opening_control">
      <field name="wkf_id" ref="wkf_pos_session"/>
      <field name="name">opening_control</field>
      <field name="action">wkf_action_opening_control()</field>
      <field name="kind">function</field>
    </record>

    <record model="workflow.activity" id="act_open">
      <field name="wkf_id" ref="wkf_pos_session"/>
      <field name="name">opened</field>
      <field name="action">wkf_action_open()</field>
      <field name="kind">function</field>
    </record>

    <record model="workflow.activity" id="act_closing_control">
      <field name="wkf_id" ref="wkf_pos_session"/>
      <field name="name">closing_control</field>
      <field name="action">wkf_action_closing_control()</field>
      <field name="kind">function</field>
    </record>

    <record model="workflow.activity" id="act_close">
      <field name="wkf_id" ref="wkf_pos_session"/>
      <field name="flow_stop">True</field>
      <field name="name">closed</field>
      <field name="action">wkf_action_close()</field>
      <field name="kind">function</field>
    </record>

    <!-- Transitions -->
    <record model="workflow.transition" id="trans_start_to_opening_control">
      <field name="act_from" ref="act_start" />
      <field name="act_to" ref="act_opening_control" />
      <field name="signal" eval="False" /> <!-- >start_to_opening_control</field> -->
      <field name="condition">cash_control == True</field>
    </record>

    <record model="workflow.transition" id="trans_start_to_open">
      <field name="act_from" ref="act_start" />
      <field name="act_to" ref="act_open" />
      <field name="signal" eval="False" />
      <field name="condition">cash_control == False</field>
    </record>
    <!-- state:opening_control -> signal:open -> state:opened -> signal:cashbox_control -> state:closing_control -> signal:close -> state:close -->

    <record model="workflow.transition" id="trans_opening_control_to_open">
      <field name="act_from" ref="act_opening_control" />
      <field name="act_to" ref="act_open" />
      <field name="signal">open</field>
    </record>

    <record model="workflow.transition" id="trans_open_to_closing_control">
      <field name="act_from" ref="act_open" />
      <field name="act_to" ref="act_closing_control" />
      <field name="signal">cashbox_control</field>
      <field name="condition">cash_control == True</field>
    </record>

    <record model="workflow.transition" id="trans_open_to_close">
      <field name="act_from" ref="act_open" />
      <field name="act_to" ref="act_closing_control" />
      <field name="signal">close</field>
      <field name="condition">cash_control == False</field>
    </record>

    <record model="workflow.transition" id="trans_closing_control_to_close">
      <field name="act_from" ref="act_closing_control" />
      <field name="act_to" ref="act_close" />
      <field name="signal">close</field>
    </record>

    <record model="workflow.transition" id="trans_closing_control_to_close_no_control">
      <field name="act_from" ref="act_closing_control" />
      <field name="act_to" ref="act_close" />
      <field name="condition">cash_control == False</field>
    </record>



  </data>
</openerp>
