<?xml version="1.0"?>
<openerp>
    <data>
        <!-- Top menu item -->
        <menuitem name="Tools" id="base.menu_tools" sequence="120" groups="base.group_tool_user"/>
    <!-- Idea Categories Search View-->
    <record model="ir.ui.view" id="view_idea_category_search">
        <field name="name">idea.category.search</field>
        <field name="model">idea.category</field>
        <field name="arch" type="xml">
            <search string="Ideas Categories">
                <field name="name" string="Category"/>
            </search>
        </field>
    </record>

    <!-- Idea Category Form View -->
        <record model="ir.ui.view" id="view_idea_category_form">
            <field name="name">idea.category.form</field>
            <field name="model">idea.category</field>
            <field name="arch" type="xml">
                <form string="Category of Ideas" version="7.0">
                    <group>
                        <field name="name"/>
                    </group>
                </form>
            </field>
        </record>

        <!-- Idea Category Tree View -->
        <record model="ir.ui.view" id="view_idea_category_tree">
            <field name="name">idea.category.tree</field>
            <field name="model">idea.category</field>
            <field name="field_parent"></field>
            <field name="arch" type="xml">
                <tree string="Category of ideas">
                    <field name="name"/>
                </tree>
            </field>
        </record>

        <!-- Idea Category Action -->

    <record model="ir.actions.act_window" id="action_idea_category">
        <field name="name">Categories</field>
        <field name="res_model">idea.category</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="search_view_id" ref="view_idea_category_search"/>
    </record>

    <menuitem name="Configuration" parent="base.menu_tools"
         id="base.menu_lunch_survey_root" sequence="20" />

    <menuitem name="Ideas" parent="base.menu_lunch_survey_root" id="menu_ideas" sequence="3"/>

    <menuitem name="Categories" parent="menu_ideas" id="menu_idea_category" action="action_idea_category" />


<!-- New Idea Form View -->

    <record model="ir.ui.view" id="view_idea_idea_form">
        <field name="name">idea.idea.form</field>
        <field name="model">idea.idea</field>
        <field name="arch" type="xml">
            <form string="Idea" version="7.0">
                <header>
                    <button name="idea_open" string="Open" states="draft" class="oe_highlight"/>
                    <button name="idea_close" string="Accept" states="open" class="oe_highlight"/>
                    <button name="idea_cancel" string="Refuse" states="open"  class="oe_highlight"/>
                    <field name="state" widget="statusbar" statusbar_visible="draft,open,close"/>
                </header>
                <sheet>
                    <label for="name" class="oe_edit_only"/>
                    <h1><field name="name"/></h1>
                    <label for="category_ids" class="oe_edit_only"/>
                    <field name="category_ids" widget="many2many_tags"/>
                    <label for="description"/><newline/>
                    <field name="description"/>
                </sheet>
                <div class="oe_chatter">
                    <field name="message_follower_ids" widget="mail_followers"/>
                    <field name="message_ids" widget="mail_thread"/>
                </div>
            </form>
        </field>
    </record>

    <!-- New Idea Tree View -->

    <record model="ir.ui.view" id="view_idea_idea_tree">
        <field name="name">idea.idea.tree</field>
        <field name="model">idea.idea</field>
        <field name="arch" type="xml">
        <tree colors="blue:state == 'draft';black:state in ('open','close');gray:state == 'cancel'" string="Ideas">
            <field name="name"/>
            <field name="create_uid"/>
            <field name="state"/>
        </tree>
        </field>
    </record>

    <!-- Search Idea  -->

    <record model="ir.ui.view" id="view_idea_idea_search">
        <field name="name">idea.idea.search</field>
        <field name="model">idea.idea</field>
        <field name="arch" type="xml">
            <search string="Ideas">
                <field name="name" string="Idea"/>
                <filter icon="terp-document-new" string="New" domain="[('state','=', 'draft')]" help="New Ideas"/>
                <filter icon="terp-camera_test" string="In Progress" domain="[('state','=', 'open')]" help="Open Ideas"/>
                <filter icon="terp-check" string="Accepted" domain="[('state','=','close')]" help="Accepted Ideas" />
                <field name="category_ids"/>
                <group expand="0" string="Group By...">
                    <filter icon="terp-personal" string="Creator" help="By Creators" context="{'group_by':'create_uid'}"/>
                    <filter icon="terp-stock_effects-object-colorize" string="Status" help="By States" context="{'group_by':'state'}"/>
                </group>
            </search>
        </field>
    </record>

    <record model="ir.actions.act_window" id="action_idea_idea">
        <field name="name">Ideas</field>
        <field name="res_model">idea.idea</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="search_view_id" ref="view_idea_idea_search"/>
    </record>

    <menuitem name="Ideas" parent="menu_ideas" id="menu_idea_idea" action="action_idea_idea" sequence="1"/>

    </data>
</openerp>
