<?xml version="1.0"?>
<openerp>
    <data>
       <menuitem name="Knowledge" icon="terp-stock"
           id="knowledge.menu_document" sequence="19" />

       <menuitem name="Configuration"
           id="knowledge.menu_document_configuration"
           parent="knowledge.menu_document" sequence="50"/>

       <menuitem name="Wiki" id="menu_wiki_configuration"
           parent="knowledge.menu_document_configuration" sequence="2" />


        <!--  Wiki Groups Tree view -->
       <record model="ir.ui.view" id="wiki_group_tree">
            <field name="name">wiki.groups.tree</field>
            <field name="model">wiki.groups</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Wiki Groups">
                    <field name="name"/>
                </tree>
            </field>
        </record>

        <!--  Wiki Groups Form view -->
        <record model="ir.ui.view" id="wiki_group_form">
            <field name="name">wiki.groups.form</field>
            <field name="model">wiki.groups</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Wiki Groups">
                    <group col="4" colspan="3" >
                        <field name="name" select="1"/>
                        <field name="create_date" readonly="2"/>
                    </group>
                    <group col="2" colspan="1">
                        <field name="method" select="1"/>
                        <field name="home" select="1" domain="[('group_id','=',active_id)]"
                            attrs="{'required':[('method','=','page')], 'readonly':[('method','!=','page')]}" />
                    </group>
                    <notebook colspan="4">
                    <page string="Notes">
                        <separator string="Group Description" colspan="4"/>
                        <field name="notes" colspan="4" nolabel="1"/>
                    </page><page string="Configuration">
                        <separator string="Page Template" colspan="4"/>
                        <field name="template" colspan="4" nolabel="1" widget="text_wiki"/>
                    </page>
                    </notebook>
                     <field name="menu_id"/>
                     <button
                         name="%(wiki.action_wiki_create_menu)d"
                         string="Create Menu"
                          type="action"
                          icon="gtk-justify-fill"
                          attrs="{'invisible':[('menu_id','!=',False)]}"/>
                     <button
                         name="open_wiki_page"
                         string="Open Wiki Page"
                          type="object"
                          icon="gtk-ok" />
                </form>
            </field>
        </record>

        <!--  Wiki Groups Action  -->
        <record model="ir.actions.act_window" id="action_wiki_groups">
            <field name="name">Wiki Groups</field>
            <field name="res_model">wiki.groups</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
        </record>

      <menuitem name="Wiki Groups"
            parent="menu_wiki_configuration"
            id="menu_action_wiki_groups"
            action="action_wiki_groups"/>

        <record model="ir.actions.act_window" id="action_wiki_groups_browse">
            <field name="name">Wiki Groups</field>
            <field name="res_model">wiki.groups</field>
            <field name="view_type">tree</field>
        </record>

        <!-- wiki Tree view For child -->
        <record id="view_wiki_tree_children" model="ir.ui.view">
            <field name="name">wiki.wiki.tree.children</field>
            <field name="model">wiki.wiki</field>
            <field name="type">tree</field>
            <field name="field_parent">child_ids</field>
            <field name="priority">100</field>
            <field name="arch" type="xml">
                <tree string="Wiki">
                    <field name="name"/>
                    <field name="section" invisible="not context.get('section',False)"/>
                    <field name="review"/>
                    <field name="write_uid"/>
                    <field name="write_date"/>
                </tree>
            </field>
        </record>

        <!-- wiki Tree view  -->
        <record model="ir.ui.view" id="view_wiki_tree">
            <field name="name">wiki.wiki.tree</field>
            <field name="model">wiki.wiki</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Wiki">
                    <field name="name"/>
                    <field name="group_id"/>
                    <field name="section" invisible="not context.get('section',False)"/>
                    <field name="review"/>
                    <field name="create_uid" invisible="context.get('create_uid',False)"/>
                    <field name="write_uid"/>
                    <field name="write_date"/>
                </tree>
            </field>
        </record>

        <!-- wiki Form view  -->
        <record model="ir.ui.view" id="view_wiki_form">
            <field name="name">wiki.wiki.form</field>
            <field name="model">wiki.wiki</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Wiki">
                    <group col="6" colspan="4">
                        <field name="name" select="1" colspan="6"/>
                        <field name="group_id" string="Topic" select="1" on_change="onchange_group_id(group_id, text_area)"/>
                        <field name="parent_id" groups="base.group_extended" domain="[('group_id','=',group_id)]"/>
                        <field name="section"/>
                    </group>
                    <notebook colspan="4">
                        <page string="Content">
                        <separator colspan="4" string="Page Content"/>
                        <field name="text_area" nolabel="1" colspan="4" select="1" widget="text_wiki"/>
                        </page>
                    </notebook>
                    <group col="2" colspan="2">
                        <separator colspan="4" string="Modification Information"/>
                        <field name="write_date" readonly="1"/>
                        <field name="minor_edit" groups="base.group_extended"/>
                        <field name="review" select="1" groups="base.group_extended"/>
                    </group>
                    <group col="2" colspan="2">
                        <separator colspan="4" string="Meta Information"/>
                        <field name="tags" select="1"/>
                        <field name="toc" groups="base.group_extended"/>
                    </group>
                </form>
            </field>
        </record>

        <!-- wiki Search view  -->
        <record id="view_wiki_filter" model="ir.ui.view">
            <field name="name">wiki.wiki.search</field>
            <field name="model">wiki.wiki</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Wiki">
                    <filter icon="terp-gtk-jump-to-ltr" string="Need Review" domain="[('review','=',True)]"/>
                    <separator orientation="vertical"/>
                    <field name="name" select="1"/>
                    <field name="group_id" select="1"/>
                    <field name="tags" select="1"/>
                    <field name="section" select="1" groups="base.group_extended"/>
                    <field name="write_uid" select="1"/>
                    <field name="write_date" select="1"/>
                    <newline/>
                    <group expand="0" string="Group By..." colspan="8" col="6">
                        <filter icon="terp-folder-blue" string="Wiki Group" domain="[]" context="{'group_by':'group_id'}"/>
                        <filter icon="terp-personal" string="Author" domain="[]" context="{'group_by':'create_uid'}"/>
                        <filter icon="terp-personal+" string="Last Contributor" domain="[]" context="{'group_by':'write_uid'}"/>
                    </group>
                </search>
            </field>
        </record>

        <!-- search page for wiki -->
        <record model="ir.actions.act_window" id="action_wiki">
            <field name="name">Wiki Pages</field>
            <field name="res_model">wiki.wiki</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="view_wiki_tree"/>
            <field name="search_view_id" ref="view_wiki_filter"/>
            <field name="help">With Wiki Pages you can share ideas and questions with your coworkers. You can create a new document that can be linked to one or several applications (CRM, Sales, etc.). You can use keywords to ease access to your wiki pages. There is a basic wiki editing for text format.</field>
        </record>

        <menuitem parent="knowledge.menu_document2"
            id="menu_action_wiki_wiki" name="Wiki Pages"
            action="action_wiki" />

        <!--  Pages Waiting Review -->
        <record model="ir.actions.act_window" id="action_wiki_review">
            <field name="name">Pages Waiting Review</field>
            <field name="res_model">wiki.wiki</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="view_wiki_tree"/>
            <field name="context">{'section':'1'}</field>
            <field name="domain">[('review','=',True)]</field>
            <field name="filter" eval="True"/>
        </record>

        <!-- History Tree view -->
        <record model="ir.ui.view" id="view_wiki_history_tree">
            <field name="name">wiki.wiki.history.tree</field>
            <field name="model">wiki.wiki.history</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Wiki History">
                    <field name="create_date"/>
                    <field name="write_uid"/>
                    <field name="minor_edit" groups="base.group_extended"/>
                    <field name="summary"/>
                </tree>
            </field>
        </record>

        <!-- History Form view  -->
        <record model="ir.ui.view" id="wiki_history_form">
            <field name="name">wiki.wiki.history.form</field>
            <field name="model">wiki.wiki.history</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Wiki History">
                    <field name="wiki_id" select="1" colspan="4"/>
                    <field name="summary" select="1" colspan="4"/>
                    <field name="text_area" select="1" colspan="4" nolabel="1" widget="text_wiki"/>
                    <field name="create_date" select="1" readonly="1"/>
                    <field name="minor_edit" select="1" groups="base.group_extended"/>
                </form>
            </field>
        </record>

        <!-- History Action  -->
        <record model="ir.actions.act_window" id="action_history">
            <field name="name">All Page Histories</field>
            <field name="res_model">wiki.wiki.history</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
        </record>

        <act_window
            context="{'search_default_wiki_id': [active_id], 'default_wiki_id': active_id}"
            id="act_wiki_wiki_history"
            name="Page History"
            res_model="wiki.wiki.history"
            src_model="wiki.wiki"/>

        <act_window
            context="{'search_default_group_id': [active_id], 'default_group_id': active_id}"
            id="act_wiki_group_open"
            name="Search Page"
            res_model="wiki.wiki"
            src_model="wiki.groups"/>

        <record id="ir_open_wiki_pages" model="ir.values">
            <field name="key2">tree_but_open</field>
            <field name="model">wiki.groups</field>
            <field name="name">Search a Page</field>
             <field eval="'ir.actions.wizard,%d'%action_view_wiki_wiki_page_open" name="value"/>
            <field eval="True" name="object"/>
        </record>

    </data>
</openerp>
