<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <menuitem id="menu_workflow_root" name="Workflow Definitions" parent="base.menu_custom" groups="base.group_extended"/>

    <!--
        ================================
        Workflows
        ================================
    -->

    <record id="view_workflow_form" model="ir.ui.view">
      <field name="name">workflow.form</field>
      <field name="model">workflow</field>
      <field name="type">form</field>
      <field name="arch" type="xml">
        <form string="Workflow">
          <field name="name"/>
          <field name="osv"/>
          <field name="on_create"/>
          <separator colspan="4" string="Activities"/>
          <field colspan="4" name="activities" nolabel="1"/>
        </form>
      </field>
    </record>

    <record id="view_workflow_search" model="ir.ui.view">
      <field name="name">workflow.search</field>
      <field name="model">workflow</field>
      <field name="type">search</field>
      <field name="arch" type="xml">
        <search string="Workflow">
          <field name="name"/>
          <field name="osv"/>
        </search>
      </field>
    </record>

    <record id="view_workflow_diagram" model="ir.ui.view">
      <field name="name">workflow.diagram</field>
      <field name="model">workflow</field>
      <field name="type">diagram</field>
      <field name="arch" type="xml">
        <diagram string="Workflow Editor">
          <node object="workflow.activity" shape="rectangle:subflow_id!=False" bgcolor="gray:flow_start==True;grey:flow_stop==True">
            <field name="name"/>
            <field name="kind"/>
            <field name="action"/>
            <field name="flow_start" invisible="1"/>
            <field name="flow_stop" invisible="1"/>
            <field name="subflow_id" invisible="1"/>
          </node>
          <arrow object="workflow.transition" source="act_from" destination="act_to" label="['signal','condition']">
            <field name="act_from"/>
            <field name="act_to"/>
            <field name="signal"/>
          </arrow>
        </diagram>
      </field>
    </record>
    <record id="view_workflow_tree" model="ir.ui.view">
      <field name="name">workflow.tree</field>
      <field name="model">workflow</field>
      <field name="type">tree</field>
      <field name="arch" type="xml">
        <tree string="Workflow">
          <field name="name"/>
          <field name="osv"/>
          <field name="on_create"/>
        </tree>
      </field>
    </record>

    <record id="action_workflow_form" model="ir.actions.act_window">
      <field name="name">Workflows</field>
      <field name="res_model">workflow</field>
      <field name="view_type">form</field>
      <field name="view_id" ref="view_workflow_tree"/>
      <field name="view_mode">tree,form,diagram</field>
    </record>
    <menuitem action="action_workflow_form" id="menu_workflow" parent="base.menu_workflow_root"/>

    <!--
        ================================
        Activities
        ================================
    -->

    <record id="view_workflow_activity_form" model="ir.ui.view">
      <field name="name">workflow.activity.form</field>
      <field name="model">workflow.activity</field>
      <field name="type">form</field>
      <field name="arch" type="xml">
        <form string="Activity">
          <field name="name"/>
          <field name="wkf_id"/>
          <group colspan="4" col="7">
            <field name="kind" colspan="4"/>
            <field name="flow_start"/>
            <field name="flow_stop"/>
          </group>
          <notebook colspan="4">
            <page string="Properties">
              <group colspan="4" col="6">
                <group colspan="1" col="2">
                  <separator string="Subflow" colspan="2"/>
                  <field name="subflow_id" attrs="{'readonly':[('kind','&lt;&gt;','subflow')]}"/>
                  <field name="signal_send"/>
                </group>
                <group colspan="1" col="2">
                  <separator string="Conditions" colspan="2"/>
                  <field name="split_mode"/>
                  <field name="join_mode"/>
                </group>
                <group colspan="1" col="2">
                  <separator string="Actions" colspan="2"/>
                  <field name="action_id"/>
                  <field name="action" attrs="{'readonly':[('kind','=','dummy')]}"/>
                </group>
              </group>
            </page>
            <page string="Transitions">
              <group colspan="4" col="4">
                <group col="2" colspan="2">
                  <field name="in_transitions" nolabel="1" height="400">
                    <tree string="Incoming Transitions">
                      <field name="act_from"/>
                      <field name="signal"/>
                      <field name="condition"/>
                    </tree>
                  </field>
                </group>
                <group col="2" colspan="2">
                  <field name="out_transitions" nolabel="1" height="400">
                    <tree string="Outgoing Transitions">
                      <field name="act_to"/>
                      <field name="signal"/>
                      <field name="condition"/>
                    </tree>
                  </field>
                </group>
              </group>
            </page>
          </notebook>
        </form>
      </field>
    </record>
    <record id="view_workflow_activity_tree" model="ir.ui.view">
      <field name="name">workflow.activity.tree</field>
      <field name="model">workflow.activity</field>
      <field name="type">tree</field>
      <field name="arch" type="xml">
        <tree string="Activity">
          <field name="name"/>
          <field name="wkf_id"/>
          <field name="kind"/>
          <field name="flow_start"/>
          <field name="flow_stop"/>
        </tree>
      </field>
    </record>

    <record id="view_workflow_activity_search" model="ir.ui.view">
      <field name="name">workflow.activity.search</field>
      <field name="model">workflow.activity</field>
      <field name="type">search</field>
      <field name="arch" type="xml">
        <search string="Workflow Activity">
          <field name="name"/>
          <field name="wkf_id"/>
          <field name="kind"/>
          <field name="action_id"/>
          <field name="action"/>
        </search>
      </field>
    </record>

    <record id="action_workflow_activity_form" model="ir.actions.act_window">
      <field name="name">Activities</field>
      <field name="res_model">workflow.activity</field>
      <field name="view_type">form</field>
      <field name="view_id" ref="view_workflow_activity_tree"/>
      <field name="search_view_id" ref="view_workflow_activity_search"/>
    </record>
    <menuitem action="action_workflow_activity_form" id="menu_workflow_activity" parent="base.menu_workflow_root"/>


    <!--
        ================================
        Transitions
        ================================
    -->

    <record id="view_workflow_transition_form" model="ir.ui.view">
      <field name="name">workflow.transition.form</field>
      <field name="model">workflow.transition</field>
      <field name="type">form</field>
      <field name="arch" type="xml">
        <form string="Transition">
          <field name="act_from"/>
          <field name="act_to"/>
          <field colspan="4" name="condition"/>
          <field name="signal"/>
          <field name="role_id"/>
          <field name="trigger_model"/>
          <field name="trigger_expr_id"/>
        </form>
      </field>
    </record>
    <record id="view_workflow_transition_tree" model="ir.ui.view">
      <field name="name">workflow.transition.tree</field>
      <field name="model">workflow.transition</field>
      <field name="type">tree</field>
      <field name="arch" type="xml">
        <tree string="Transition">
          <field name="act_from"/>
          <field name="act_to"/>
          <field name="signal"/>
          <field name="condition"/>
        </tree>
      </field>
    </record>

    <record id="view_workflow_transition_search" model="ir.ui.view">
      <field name="name">workflow.transition.search</field>
      <field name="model">workflow.transition</field>
      <field name="type">search</field>
      <field name="arch" type="xml">
        <search string="Transition">
          <field name="act_from"/>
          <field name="act_to"/>
          <field name="condition"/>
        </search>
      </field>
    </record>

    <record id="action_workflow_transition_form" model="ir.actions.act_window">
      <field name="name">Transitions</field>
      <field name="res_model">workflow.transition</field>
      <field name="view_type">form</field>
      <field name="view_id" ref="view_workflow_transition_tree"/>
      <field name="search_view_id" ref="view_workflow_transition_search"/>
    </record>
    <menuitem action="action_workflow_transition_form" id="menu_workflow_transition" parent="base.menu_workflow_root"/>

    <!--
        ================================
        Instances
        ================================
    -->

    <record id="view_workflow_instance_form" model="ir.ui.view">
      <field name="name">workflow.instance.form</field>
      <field name="model">workflow.instance</field>
      <field name="type">form</field>
      <field name="arch" type="xml">
        <form string="Workflow Instances">
          <field name="wkf_id" readonly="1"/>
          <field name="uid" readonly="1"/>
          <field name="res_id" readonly="1"/>
          <field name="res_type" readonly="1"/>
          <field name="state" readonly="1"/>
        </form>
      </field>
    </record>
    <record id="view_workflow_instance_tree" model="ir.ui.view">
      <field name="name">workflow.instance.tree</field>
      <field name="model">workflow.instance</field>
      <field name="type">tree</field>
      <field name="arch" type="xml">
        <tree string="Workflow Instances">
          <field name="wkf_id"/>
          <field name="uid"/>
          <field name="res_id"/>
          <field name="res_type"/>
          <field name="state"/>
        </tree>
      </field>
    </record>
    <record id="view_workflow_instance_search" model="ir.ui.view">
      <field name="name">workflow.instance.search</field>
      <field name="model">workflow.instance</field>
      <field name="type">search</field>
      <field name="arch" type="xml">
        <search string="Workflow Instances">
          <field name="wkf_id"/>
          <field name="uid"/>
          <field name="res_id"/>
          <field name="res_type"/>
          <field name="state"/>
        </search>
      </field>
    </record>

    <record id="action_workflow_instance_form" model="ir.actions.act_window">
      <field name="name">Instances</field>
      <field name="res_model">workflow.instance</field>
      <field name="view_type">form</field>
      <field name="view_id" ref="view_workflow_instance_tree"/>
      <field name="search_view_id" ref="view_workflow_instance_search"/>
    </record>
    <menuitem action="action_workflow_instance_form" id="menu_workflow_instance" parent="base.menu_low_workflow"/>

    <!--
        ================================
        Workitems
        ================================
    -->

    <record id="view_workflow_workitem_form" model="ir.ui.view">
      <field name="name">workflow.workitem.form</field>
      <field name="model">workflow.workitem</field>
      <field name="type">form</field>
      <field name="arch" type="xml">
        <form string="Workflow Workitems">
          <field name="act_id" readonly="1"/>
          <field name="subflow_id" readonly="1"/>
          <field name="inst_id" readonly="1"/>
          <field name="state" readonly="1"/>
        </form>
      </field>
    </record>
    <record id="view_workflow_workitem_tree" model="ir.ui.view">
      <field name="name">workflow.workitem.tree</field>
      <field name="model">workflow.workitem</field>
      <field name="type">tree</field>
      <field name="arch" type="xml">
        <tree string="Workflow Workitems">
          <field name="act_id"/>
          <field name="subflow_id"/>
          <field name="inst_id"/>
          <field name="state"/>
        </tree>
      </field>
    </record>
    <record id="view_workflow_workitem_search" model="ir.ui.view">
      <field name="name">workflow.workitem.search</field>
      <field name="model">workflow.workitem</field>
      <field name="type">search</field>
      <field name="arch" type="xml">
        <search string="Workflow Workitems">
          <field name="act_id"/>
          <field name="subflow_id"/>
          <field name="inst_id"/>
          <field name="state"/>
        </search>
      </field>
    </record>

    <record id="action_workflow_workitem_form" model="ir.actions.act_window">
      <field name="name">Workitems</field>
      <field name="res_model">workflow.workitem</field>
      <field name="view_type">form</field>
      <field name="view_id" ref="view_workflow_workitem_tree"/>
      <field name="search_view_id" ref="view_workflow_workitem_search"/>
    </record>
    <menuitem action="action_workflow_workitem_form" id="menu_workflow_workitem" parent="base.menu_low_workflow"/>

  </data>
</openerp>
