<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <menuitem icon="STOCK_PREFERENCES" id="base.menu_tools" name="Tools" sequence="28"/>
        <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="type">form</field>
            <field name="arch" type="xml">
                <form string="Subscriptions">
                    <group colspan="4">
                        <field name="name" select="1"/>
                        <field name="active" select="1" groups="base.group_extended"/>
                        <field name="user_id" select="1"/>
                        <field name="partner_id" select="1"/>
                    </group>
                    <notebook colspan="4">
                        <page string="Subsription Data">
                            <newline/>
                            <field name="interval_number"/>
                            <field name="interval_type"/>
                            <field name="exec_init"/>
                            <field name="date_init"/>
                            <field colspan="4" name="doc_source" widget="reference"/>
                            <separator string="Notes"  colspan="4"/>
                            <field colspan="4" name="notes" nolabel="1"/>
                            <separator colspan="4"/>
                            <field colspan="4" name="cron_id" readonly="1"/>
                            <field name="state" readonly="1"/>
                            <group col="3" colspan="2">
                                <button name="set_process" states="draft" string="Process" type="object" icon="gtk-go-forward"/>
                                <button name="set_done" states="running" string="Stop" type="object" icon="gtk-stop"/>
                                <button name="set_draft" states="done" string="Set to Draft" type="object" icon="gtk-convert"/>
                            </group>
                        </page>
                        <page string="Documents created">
                            <field colspan="4" name="doc_lines" nolabel="1" widget="one2many_list"/>
                        </page>
                        <page string="Notes">
                            <separator string="Notes" colspan="4"/>
                            <field name="note" colspan="4" nolabel="1"/>
                    </page>
                    </notebook>
                </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="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Subscriptions">
                    <field name="name"/>
                    <field name="partner_id"/>
                    <field name="active" groups="base.group_extended"/>
                    <field name="user_id" select="1"/>
                    <field name="state"/>
                    <button name="set_process" states="draft" string="Process" type="object" icon="terp-check"/>
                    <button name="set_done" states="running" string="Done" type="object" icon="terp-gtk-stop"/>
                    <button name="set_draft" states="done" string="Set to Draft" type="object" icon="terp-document-new"/>
                </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="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Subscription">
                    <group col="10" colspan="4">
                        <filter icon="terp-check"
                        string="Running"
                        domain="[('state','=','running')]"/>
                        <separator orientation="vertical"/>
                        <filter string="This Week" icon="terp-go-week" domain="[('date_init','&lt;=', time.strftime('%%Y-%%m-%%d')), ('date_init','&gt;',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"/>
                        <filter icon="terp-go-today" string="Today"
                    domain="[('date_init','&lt;', time.strftime('%%Y-%%m-%%d 23:59:59')), ('date_init','&gt;=', time.strftime('%%Y-%%m-%%d 00:00:00'))]"/>
                        <separator orientation="vertical"/>
                        <field name="name"/>
                        <field name="user_id" select="1"/>
                        <field name="partner_id"/>
                    </group>
                    <newline/>
                    <group expand="0" string="Group By..." colspan="4" col="4">
                        <filter string="User" icon="terp-personal" name="User" domain="[]" context="{'group_by':'user_id'}"/>
                        <filter string="Partner" icon="terp-personal" name="Partner" domain="[]" context="{'group_by':'partner_id'}"/>
                        <separator orientation="vertical"/>
                        <filter string="State" 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="type">tree</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="type">form</field>
            <field name="arch" type="xml">
                <form string="Subscription History">
                    <field name="date"/>
                    <field colspan="4" name="document_id"/>
                </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="type">form</field>
            <field name="arch" type="xml">
                <form string="Subscription Document">
                    <field name="name" select="1"/>
                    <field name="active" select="1"/>
                    <field name="model" select="1"/>
                    <field colspan="4" name="field_ids" nolabel="1"/>
                </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="type">tree</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="type">search</field>
            <field name="arch" type="xml">
                <search string="Subscription Document">
                    <group col="10" colspan="4">
                        <field name="name"/>
                        <field name="model"/>
                    </group>
                </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="type">form</field>
            <field name="arch" type="xml">
                <form string="Subscription Document Fields">
                    <field name="field" select="1"/>
                    <newline/>
                    <field name="value"/>
                </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="type">tree</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_system" />
        <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>
