<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

        <!-- Marketing Campaigns -->
        <record id="wkf_marketing_campaign" model="workflow">
            <field name="name">marketing.campaign.basic</field>
            <field name="osv">marketing.campaign</field>
            <field name="on_create">True</field>
        </record>

        <!-- Activity -->
        <record id="act_marketing_campaign_draft" model="workflow.activity">
            <field name="wkf_id" ref="wkf_marketing_campaign"/>
            <field name="flow_start">True</field>
            <field name="name">draft</field>
            <field name="kind">function</field>
            <field name="action">write({'state':'draft'})</field>
        </record>

        <record id="act_marketing_campaign_running" model="workflow.activity">
            <field name="wkf_id" ref="wkf_marketing_campaign"/>
            <field name="name">running</field>
            <field name="kind">function</field>
            <field name="action">state_running_set()</field>
        </record>

        <record id="act_marketing_campaign_done" model="workflow.activity">
            <field name="wkf_id" ref="wkf_marketing_campaign"/>
            <field name="name">done</field>
            <field name="kind">function</field>
            <field name="action">state_done_set()</field>
        </record>

        <record id="act_marketing_campaign_cancel" model="workflow.activity">
            <field name="wkf_id" ref="wkf_marketing_campaign"/>
            <field name="name">cancel</field>
            <field name="flow_stop" eval="False"/>
            <field name="kind">function</field>
            <field name="action">state_cancel_set()</field>
        </record>

        <!-- Transition -->
        <record id="trans_marketing_campaign_draft_running" model="workflow.transition">
            <field name="act_from" ref="act_marketing_campaign_draft"/>
            <field name="act_to" ref="act_marketing_campaign_running"/>
            <field name="signal">state_running_set</field>
        </record>

        <record id="trans_campaign_running_done" model="workflow.transition">
            <field name="act_from" ref="act_marketing_campaign_running"/>
            <field name="act_to" ref="act_marketing_campaign_done"/>
            <field name="signal">state_done_set</field>
        </record>

        <record id="trans_campaign_running_cancel" model="workflow.transition">
            <field name="act_from" ref="act_marketing_campaign_running"/>
            <field name="act_to" ref="act_marketing_campaign_cancel"/>
            <field name="signal">state_cancel_set</field>
        </record>

        <record id="trans_campaign_done_draft" model="workflow.transition">
            <field name="act_from" ref="act_marketing_campaign_done"/>
            <field name="act_to" ref="act_marketing_campaign_draft"/>
            <field name="signal">state_draft_set</field>
        </record>

        <record id="trans_campaign_cancelled_draft" model="workflow.transition">
            <field name="act_from" ref="act_marketing_campaign_cancel"/>
            <field name="act_to" ref="act_marketing_campaign_draft"/>
            <field name="signal">state_draft_set</field>
        </record>

         <!-- Marketing Campaign Segment -->
        <record id="wkf_marketing_campaign_segment" model="workflow">
            <field name="name">marketing.campaign.segment.basic</field>
            <field name="osv">marketing.campaign.segment</field>
            <field name="on_create">True</field>
        </record>

        <!-- Activity -->
        <record id="act_marketing_campaign_segment_draft" model="workflow.activity">
            <field name="wkf_id" ref="wkf_marketing_campaign_segment"/>
            <field name="flow_start">True</field>
            <field name="name">draft</field>
            <field name="kind">function</field>
            <field name="action">write({'state': 'draft'})</field>
        </record>

        <record id="act_marketing_campaign_segment_running" model="workflow.activity">
            <field name="wkf_id" ref="wkf_marketing_campaign_segment"/>
            <field name="name">running</field>
            <field name="kind">function</field>
            <field name="action">state_running_set()</field>
        </record>

        <record id="act_marketing_campaign_segment_done" model="workflow.activity">
            <field name="wkf_id" ref="wkf_marketing_campaign_segment"/>
            <field name="name">done</field>
            <field name="kind">function</field>
            <field name="action">state_done_set()</field>
        </record>

        <record id="act_marketing_campaign_segment_cancel" model="workflow.activity">
            <field name="wkf_id" ref="wkf_marketing_campaign_segment"/>
            <field name="name">cancel</field>
            <field name="kind">function</field>
            <field name="action">state_cancel_set()</field>
            <field name="flow_stop" eval="False"/>
        </record>

        <!-- Transition -->
        <record id="trans_marketing_campaign_segment_draft_running" model="workflow.transition">
            <field name="act_from" ref="act_marketing_campaign_segment_draft"/>
            <field name="act_to" ref="act_marketing_campaign_segment_running"/>
            <field name="signal">state_running_set</field>
        </record>

        <record id="trans_campaign_segment_running_done" model="workflow.transition">
            <field name="act_from" ref="act_marketing_campaign_segment_running"/>
            <field name="act_to" ref="act_marketing_campaign_segment_done"/>
            <field name="signal">state_done_set</field>
        </record>

        <record id="trans_campaign_segment_running_cancel" model="workflow.transition">
            <field name="act_from" ref="act_marketing_campaign_segment_running"/>
            <field name="act_to" ref="act_marketing_campaign_segment_cancel"/>
            <field name="signal">state_cancel_set</field>
        </record>

        <record id="trans_campaign_segment_set_to_draft" model="workflow.transition">
            <field name="act_from" ref="act_marketing_campaign_segment_cancel"/>
            <field name="act_to" ref="act_marketing_campaign_segment_draft"/>
            <field name="signal">state_draft_set</field>
        </record>

        <record id="trans_campaign_segment_done_draft" model="workflow.transition">
            <field name="act_from" ref="act_marketing_campaign_segment_done"/>
            <field name="act_to" ref="act_marketing_campaign_segment_draft"/>
            <field name="signal">state_draft_set</field>
        </record>

    </data>
</openerp>
