<?xml version="1.0"?>
<openerp>
    <data>
    <menuitem name="Tools" id="menu_tools" icon="STOCK_PREFERENCES" />
        <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="type">form</field>
            <field name="arch" type="xml">
                <form string="Category of ideas">
                    <field name="name" select="1"/>
                    <field name="parent_id" select="1"/>
                    <newline/>
                    <field name="summary" select="2" colspan="4"/>
                </form>
            </field>
        </record>
        <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="type">tree</field>
            <field name="field_parent">child_ids</field>
            <field name="arch" type="xml">
                <tree string="Category of ideas">
                    <field name="name"/>
                </tree>
            </field>
        </record>
    <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>
    </record>
    <menuitem name="Configuration" parent="menu_tools" id="menu_config"/>
    <menuitem name="Ideas" parent="menu_config" id="menu_ideas"/>
    <menuitem name="Categories" parent="menu_ideas" id="menu_idea_category" action="action_idea_category"/>

    <record model="ir.actions.act_window" id="action_idea_category_tree">
        <field name="name">Ideas by Categories</field>
        <field name="res_model">idea.category</field>
        <field name="view_type">tree</field>
        <field name="domain">[('parent_id','=',False)]</field>
    </record>
    <menuitem name="Ideas" parent="menu_tools" id="menu_ideas1"/>
    <menuitem 
        name="Ideas by Categories" parent="menu_ideas1" 
        id="menu_idea_category_tree" 
        action="action_idea_category_tree"/>


    <record model="ir.actions.act_window" id="action_idea_idea_categ_open">
        <field name="name">Open Ideas</field>
        <field name="res_model">idea.idea</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="domain">[('state','=','open'),('category_id','child_of',[active_id])]</field>
    </record>
    <record model="ir.values" id="action_idea_idea_categ_open_val">
        <field name="key2" eval=" 'tree_but_open'" />
        <field name="model" eval="'idea.category'" />
        <field name="name">Ideas</field>
        <field name="value" eval="'ir.actions.act_window,'+str(action_idea_idea_categ_open)" />
        <field name="object" eval="True" />
    </record>

    <record model="ir.ui.view" id="view_idea_stat_form">
        <field name="name">idea.stat.form</field>
        <field name="model">idea.stat</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="stat">
                <field name="avgscore" />
                <field name="nbr_comments" />
                <field name="nbr_votes" />
            </form>
        </field>
    </record>

    <record model="ir.ui.view" id="view_idea_vote_tree">
        <field name="name">idea.vote.tree</field>
        <field name="model">idea.vote</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
        <tree string="Votes">
            <field name="idea_id"/>
            <field name="user_id"/>
            <field name="score" />
        </tree>
        </field>
    </record>
    <record model="ir.ui.view" id="view_idea_vote_form">
        <field name="name">idea.vote.form</field>
        <field name="model">idea.vote</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
        <form string="Votes">
            <field name="idea_id" select="1" />
            <field name="user_id" select="1" />
            <field name="score" select="2"/>
        </form>
        </field>
    </record>

    <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="type">form</field>
        <field name="arch" type="xml">
        <form string="New Idea">
            <notebook>
                <page string="Idea">
                    <field name="title" select="1" />
                    <field name="category_id" select="1"/>
                    <field name="user_id" select="1"/>
                    <field name="my_vote"/>
                    <field name="vote_avg" />
                    <field name="description" colspan="4" select="2" widget="text_wiki"/>
                    <field name="state" select="2"/>
                    <group colspan="2" col="3">
                        <button name="idea_open" string="Open" states="draft"/>
                        <button name="idea_close" string="Close" states="open"/>
                        <button name="idea_cancel" string="Cancel" states="open" />
                    </group>
                </page>
                <page string="Comments">
                    <field name="comment_ids" nolabel="1" colspan="4">
                        <form string="Comment">
                            <separator string="Your comment" colspan="4"/>
                            <field name="content" nolabel="1" />
                        </form>
                    </field>
                </page>
                <page string="Statistics">
                    <field name="stat_vote_ids" colspan="4" mode="graph,tree" nolabel="1">
                        <graph string="vote_stat of ideas" type="bar">
                            <field name="score"/>
                            <field name="nbr"/>
                        </graph>
                        <tree string="vote_stat of ideas">
                            <field name="score"/>
                            <field name="nbr"/>
                        </tree>
                    </field>
                </page>
            </notebook>
        </form>
        </field>
    </record>

    <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="type">tree</field>
        <field name="arch" type="xml">
        <tree string="All Ideas">
            <field name="category_id" />
            <field name="create_date"/> 
            <field name="user_id" />
            <field name="title"/>
            <field name="vote_avg" />
            <field name="count_comments" />
            <field name="count_votes" />
        </tree>
        </field>
    </record>

    <record model="ir.ui.view" id="view_idea_comment_tree">
        <field name="name">idea.comment.tree</field>
        <field name="model">idea.comment</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
        <tree string="Comments">
            <field name="create_date" />
            <field name="user_id" />
            <field name="content" string="Comment" />
        </tree>
        </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>
    </record>
    <menuitem name="All Ideas" parent="menu_ideas1" id="menu_idea_idea" action="action_idea_idea"/>

    <record model="ir.actions.act_window" id="action_idea_idea_open">
        <field name="name">Open Ideas</field>
        <field name="res_model">idea.idea</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="domain">[('state','=','open')]</field>
    </record>
    <menuitem name="Open Ideas" parent="menu_idea_idea" id="menu_idea_idea_open" action="action_idea_idea_open"/>


    <record model="ir.actions.act_window" id="action_idea_idea_my_idea">
        <field name="name">My Ideas</field>
        <field name="res_model">idea.idea</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="domain">[('user_id', '=', uid)]</field>
    </record>
    <menuitem name="My Ideas" parent="menu_ideas1" id="menu_idea_idea_my_idea" action="action_idea_idea_my_idea" />

    <record model="ir.actions.act_window" id="action_idea_idea_draft_my">
        <field name="name">My Draft Ideas</field>
        <field name="res_model">idea.idea</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="domain">[('state','=','draft'),('user_id','=',uid)]</field>
    </record>
    <menuitem 
        name="My Draft Ideas" parent="menu_idea_idea_my_idea"
        id="menu_idea_idea_draft_my" 
        action="action_idea_idea_draft_my"/>


    <record model="ir.actions.act_window" id="action_idea_idea_open_my">
        <field name="name">My Open Ideas</field>
        <field name="res_model">idea.idea</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="domain">[('state','=','open'),('user_id','=',uid)]</field>
    </record>
    <menuitem 
        name="My Open Ideas" parent="menu_idea_idea_my_idea"
        id="menu_idea_idea_open_my"
        action="action_idea_idea_open_my"/>

        <record model="ir.ui.view" id="view_idea_vote_stat_graph">
            <field name="name">idea.vote_stat.graph</field>
            <field name="model">idea.vote.stat</field>
            <field name="type">graph</field>
            <field name="arch" type="xml">
                <graph string="vote_stat of ideas">
                    <field name="score"/>
                    <field name="nbr"/>
                </graph>
            </field>
        </record>

        <record model="ir.ui.view" id="view_idea_vote_stat_form">
            <field name="name">idea.vote.stat.form</field>
            <field name="model">idea.vote.stat</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="vote_stat of ideas">
                    <field name="idea_id" select="1"/>
                    <field name="score"  select="1"/>
                    <field name="nbr"  select="2"/>
                </form>
            </field>
        </record>
        <record model="ir.ui.view" id="view_idea_vote_stat_tree">
            <field name="name">idea.vote.stat.tree</field>
            <field name="model">idea.vote.stat</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="vote_stat of ideas">
                    <field name="idea_id"/>
                    <field name="score" />
                    <field name="nbr" />
                </tree>
            </field>
        </record>

    <record model="ir.actions.act_window" id="action_idea_vote_stat">
        <field name="name">Statistics on Votes</field>
        <field name="res_model">idea.vote.stat</field>
        <field name="view_type">form</field>
        <field name="view_mode">graph,tree</field>
    </record>
    <menuitem name="Reporting" parent="menu_ideas1" id="menu_reporting"/>
    <menuitem name="Vote Statistics" parent="menu_reporting" id="menu_idea_vote_stat" action="action_idea_vote_stat"/>


    <record model="ir.actions.act_window" id="action_idea_vote">
        <field name="name">Idea's vote</field>
        <field name="res_model">idea.vote</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
    </record>
    <menuitem name="All Votes" parent="menu_ideas" id="menu_idea_vote" action="action_idea_vote"/>

    </data>
</openerp>
