<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <!-- Top menu item -->
        <menuitem name="Tools" id="base.menu_tools" sequence="120" groups="base.group_tool_user"/>
        <menuitem id="next_id_45" name="Recurring Events" parent="base.menu_tools" sequence="4"/>

        <!-- Subscription Views -->
        <record id="view_subscription_form" model="ir.ui.view">
            <field name="name">subscription.subscription.form</field>
            <field name="model">subscription.subscription</field>
            <field name="arch" type="xml">
                <form string="Subscriptions" version="7.0">
                <header>
                    <button name="set_process" states="draft" string="Process" type="object" class="oe_highlight"/>
                    <button name="set_done" states="running" string="Stop" type="object" class="oe_highlight"/>
                    <button name="set_draft" states="done" string="Set to Draft" type="object"/>
                    <field name="state" widget="statusbar" statusbar_visible="draft,running"/>
                </header>
                <sheet>
                    <group col="4">
                        <field name="name"/>
                        <field name="partner_id"/>
                        <field name="user_id"/>
                        <field name="active"/>
                    </group>
                    <notebook>
                        <page string="Subsription Data">
                            <group col="4">
                                <field name="interval_number"/>
                                <field name="interval_type"/>
                                <field name="exec_init"/>
                                <field name="date_init"/>
                                <field name="doc_source" widget="reference"/>
                                <field name="cron_id"/>
                            </group>
                            <separator string="Notes"/>
                            <field name="notes"/>
                        </page>
                        <page string="Documents created">
                            <field name="doc_lines" widget="one2many_list"/>
                        </page>
                        <page string="Notes">
                            <field name="note"/>
                        </page>
                    </notebook>
                    </sheet>
                </form>
            </field>
        </record>

        <record id="view_subscription_tree" model="ir.ui.view">
            <field name="name">subscription.subscription.tree</field>
            <field name="model">subscription.subscription</field>
            <field name="arch" type="xml">
                <tree string="Subscriptions">
                    <field name="name"/>
                    <field name="partner_id"/>
                    <field name="active"/>
                    <field name="user_id"/>
                    <field name="state"/>
                </tree>
            </field>
        </record>

        <record id="view_subscription_filter" model="ir.ui.view">
            <field name="name">subscription.subscription.filter</field>
            <field name="model">subscription.subscription</field>
            <field name="arch" type="xml">
                <search string="Search Subscription">
                    <field name="name" string="Subscription"/>
                    <field name="date_init"/>
                    <filter icon="terp-check"
                            string="Running"
                            domain="[('state','=','running')]"/>
                    <field name="user_id"/>
                    <field name="partner_id"/>
                    <group expand="0" string="Group By...">
                        <filter string="User" icon="terp-personal" name="User" domain="[]" context="{'group_by':'user_id'}"/>
                        <filter string="Partner" icon="terp-partner" name="Partner" domain="[]" context="{'group_by':'partner_id'}"/>
                        <filter string="Status" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
                    </group>
                </search>
            </field>
        </record>

        <record id="action_subscription_form" model="ir.actions.act_window">
            <field name="name">Subscriptions</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">subscription.subscription</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="view_subscription_tree"/>
            <field name="context">{'search_default_User':1}</field>
            <field name="search_view_id" ref="view_subscription_filter"/>
        </record>
        <menuitem action="action_subscription_form" id="menu_action_subscription_form" parent="subscription.next_id_45"/>

        <record id="subscription_subscription_history_tree" model="ir.ui.view">
            <field name="name">subscription.subscription.history.tree</field>
            <field name="model">subscription.subscription.history</field>
            <field name="arch" type="xml">
                <tree string="Subscription History">
                    <field name="date"/>
                </tree>
            </field>
        </record>

        <record id="subscription_subscription_history_form" model="ir.ui.view">
            <field name="name">subscription.subscription.history.form</field>
            <field name="model">subscription.subscription.history</field>
            <field name="arch" type="xml">
                <form string="Subscription History" version="7.0">
                    <group col="4">
                        <field name="date"/>
                        <field name="document_id"/>
                    </group>
                </form>
            </field>
        </record>

        <record id="document_form" model="ir.ui.view">
            <field name="name">subscription.document.form</field>
            <field name="model">subscription.document</field>
            <field name="arch" type="xml">
                <form string="Subscription Document" version="7.0">
                    <group col="4">
                        <field name="name"/>
                        <field name="model"/>
                        <field name="active"/>
                    </group>
                    <field name="field_ids"/>
                </form>
            </field>
        </record>

        <record id="document_tree" model="ir.ui.view">
            <field name="name">subscription.document.tree</field>
            <field name="model">subscription.document</field>
            <field name="arch" type="xml">
                <tree string="Subscription Document">
                    <field name="name"/>
                    <field name="active"/>
                    <field name="model"/>
                </tree>
            </field>
        </record>

        <record id="view_subscription_document_filter" model="ir.ui.view">
            <field name="name">subscription.document.filter</field>
            <field name="model">subscription.document</field>
            <field name="arch" type="xml">
                <search string="Subscription Document">
                    <field name="name" string="Subscription Document"/>
                    <field name="model"/>
                </search>
            </field>
        </record>

        <record id="document_fields_form" model="ir.ui.view">
            <field name="name">subscription.document.fields.form</field>
            <field name="model">subscription.document.fields</field>
            <field name="arch" type="xml">
                <form string="Subscription Document Fields" version="7.0">
                    <group>
                        <field name="field"/>
                        <field name="value"/>
                    </group>
                </form>
            </field>
        </record>

        <record id="document_fields_tree" model="ir.ui.view">
            <field name="name">subscription.document.fields.tree</field>
            <field name="model">subscription.document.fields</field>
            <field name="arch" type="xml">
                <tree string="Subscription Document Fields">
                    <field name="field"/>
                    <field name="value"/>
                </tree>
            </field>
        </record>

        <record id="action_document_form" model="ir.actions.act_window">
            <field name="name">Document Types</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">subscription.document</field>
            <field name="view_type">form</field>
            <field name="view_id" ref="document_tree"/>
            <field name="search_view_id" ref="view_subscription_document_filter"/>
        </record>
        <menuitem name="Configuration" parent="base.menu_tools"
              id="base.menu_lunch_survey_root" sequence="20" groups="base.group_tool_manager"/>
        <menuitem id="config_recuuring_event" name="Recurring Events" parent="base.menu_lunch_survey_root" sequence="4"/>
        <menuitem action="action_document_form" id="menu_action_document_form" parent="config_recuuring_event"/>

    </data>
</openerp>
