<?xml version="1.0"?>
<openerp>
    <data>
        <menuitem name="Document Management" icon="terp-stock" id="menu_document2"/>
        <menuitem name="Wiki Configuration" id="menu_document_configuration" parent="menu_document2"/>
        <menuitem parent="menu_document2" name="Wiki" id="menu_document"/>

        <wizard
            id="wizard_group_menu_create"
            string="Create Menu"
            menu="True"
            name="wiki.create.menu"/>
            
        <wizard
            id="wizard_open_page"
            string="Open Page"
            menu="True"
            name="wiki.wiki.page.open"/>
            
        <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="field_parent">child_ids</field>
            <field name="arch" type="xml">
                <tree string="Wiki Groups">
                    <field name="name"/>
                </tree>
            </field>
        </record>
        <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 colspan="4" col="4">
                        <field name="name" select="1"/>
                        <field name="parent_id" select="2"/>
                        <field name="create_date" readonly="2"/>
                        <field name="section"/>
                    </group>
                    <notebook colspan="4">
                    <page string="Notes">
                        <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>
                    <button
                        name="%(wizard_group_menu_create)d"
                        string="Create a Menu"
                        type="action"
                        target="new"/>
                </form>
            </field>
        </record>

        <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
            parent="menu_document_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="domain">[('parent_id','=',False)]</field>
            <field name="view_type">tree</field>
        </record>
        <menuitem
            parent="menu_document"
            id="menu_action_wiki_groups_browse"
            action="action_wiki_groups_browse"/>

        <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="section" invisible="not context.get('section',False)"/>
                    <field name="group_id" invisible="context.get('group_id',False)"/>
                    <field name="review"/>
                    <field name="write_uid"/>
                    <field name="write_date"/>
                </tree>
            </field>
        </record>

        <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"/>
                        <field name="group_id" select="1" on_change="onchange_group_id(group_id, text_area)"/>
                        <field name="section" select="2" invisible="not context.get('section',False)"/>
                    </group>
                    <field name="text_area" nolabel="1" colspan="4" select="1" widget="text_wiki"/>
                    <separator colspan="4" string="Modifications"/>
                    <group col="6" colspan="4">
                        <field name="write_date" readonly="1" select="2"/>
                        <field name="review" select="1"/>
                        <field name="toc"/>
                        <field name="tags" select="2" groups="base.group_extended"/>
                        <field name="summary" colspan="4" select="2" groups="base.group_extended"/>
                    </group>
                </form>
            </field>
        </record>

        <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="context">{'section':'1'}</field>
        </record>
        <menuitem
            parent="menu_document"
            id="menu_action_wiki_wiki"
            string="All Wiki Pages"
            action="action_wiki"/>

        <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>
        
        <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"/>
                    <field name="minor_edit" select="1" groups="base.group_extended"/>
                </form>
            </field>
        </record>

        <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>
        <menuitem
            parent="menu_document_configuration"
            id="menu_action_history"
            action="action_history"/>

        <act_window domain="[('wiki_id', '=', active_id)]"
            id="act_wiki_wiki_history"
            name="History"
            res_model="wiki.wiki.history"
            src_model="wiki.wiki"/>

        <act_window
            domain="[('group_id', 'child_of', active_ids)]"
            id="act_wiki_group_open"
            name="Wiki Pages"
            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">Wiki Pages</field>
            <field eval="'ir.actions.act_window,%d'%act_wiki_group_open" name="value"/>
            <field eval="True" name="object"/>
        </record>

    </data>
</openerp>
