<?xml version="1.0"?>
<odoo>

    <!-- wiki tree view -->
    <record id="view_wiki_tree_children" model="ir.ui.view">
        <field name="name">document.page.tree</field>
        <field name="model">document.page</field>
        <field name="field_parent">child_ids</field>
        <field name="priority">100</field>
        <field name="arch" type="xml">
            <tree string="Document Page">
                <field name="name"/>
                <field name="content_uid"/>
                <field name="content_date"/>
            </tree>
        </field>
    </record>

    <!-- wiki list view  -->
    <record id="view_wiki_tree" model="ir.ui.view">
        <field name="name">document.page.list</field>
        <field name="model">document.page</field>
        <field name="arch" type="xml">
            <tree string="Document Page">
                <field name="name"/>
                <field name="parent_id"/>
                <field name="create_uid" invisible="1"/>
                <field name="content_uid"/>
                <field name="content_date"/>
            </tree>
        </field>
    </record>

    <!-- wiki Form view  -->
    <record id="view_wiki_form" model="ir.ui.view">
        <field name="name">document.page.form</field>
        <field name="model">document.page</field>
        <field name="arch" type="xml">
            <form string="Document Page">
                <sheet>
                    <field name="type" invisible="1"/>
                    <h1><field name="name" placeholder="Name"/></h1>
                    <group>
                        <group>
                            <field name="parent_id" string="Category" context="{'default_type':'category'}"/>
                        </group>
                        <group>
                            <field name="content_uid"/>
                            <field name="content_date"/>
                            <field name="menu_id" readonly="1" attrs="{'invisible': [('menu_id','=',False)]}"/>
                        </group>
                    </group>
                    <notebook>
                        <page name="content" string="Content">
                            <label for="summary" class="oe_edit_only" />
                            <field name="summary" placeholder="eg: Changed ... for ..." class="oe_edit_only" />
                            <label for="content" class="oe_edit_only"/>
                            <field name="content" widget="html" placeholder="e.g. Once upon a time..." required="1" options="{'safe': True}"/>
                        </page>
                        <page name="history" string="History">
                            <field name="history_ids">
                                <tree>
                                    <field name="id"/>
                                    <field name="create_date"/>
                                    <field name="summary"/>
                                    <field name="create_uid"/>
                                </tree>
                            </field>
                        </page>
                    </notebook>
                </sheet>
                <div class="oe_chatter">
                    <field name="message_follower_ids" widget="mail_followers"/>
                    <field name="message_ids" widget="mail_thread"/>
                </div>
            </form>
        </field>
    </record>

    <record id="view_wiki_menu_form" model="ir.ui.view">
        <field name="name">document.page.menu.form</field>
        <field name="model">document.page</field>
        <field name="arch" type="xml">
            <form string="Document Page">
                <field name="type" invisible="1"/>
                <h1><field name="name" placeholder="Name"/></h1>
                <field name="content" class="oe_view_only" required="1" options='{"safe": True}'/>
            </form>
        </field>
    </record>

    <!-- page Search view  -->
    <record id="view_wiki_filter" model="ir.ui.view">
        <field name="name">document.page.search</field>
        <field name="model">document.page</field>
        <field name="arch" type="xml">
            <search string="Document Page">
                <field name="name" string="Content" filter_domain="['|', ('name','ilike',self), ('content','ilike',self)]"/>
                <field name="parent_id"/>
                <field name="create_uid"/>
                <field name="content_uid"/>
                <group expand="0" string="Group By...">
                    <filter string="Category" context="{'group_by':'parent_id'}" />
                    <filter string="Author" context="{'group_by':'create_uid'}" />
                    <filter string="Last Contributor" context="{'group_by':'content_uid'}" />
                </group>
            </search>
        </field>
    </record>


    <!-- page action -->
    <record id="action_page" model="ir.actions.act_window">
        <field name="name">Pages</field>
        <field name="res_model">document.page</field>
        <field name="domain">[('type','=','content')]</field>
        <field name="context">{'default_type': 'content'}</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" type="html">
          <p class="oe_view_nocontent_create">
            Click to create a new web page.
          </p>
        </field>
    </record>

    <record id="action_page_view_tree" model="ir.actions.act_window.view">
        <field name="sequence" eval="0" />
        <field name="view_mode">tree</field>
        <field name="view_id" ref="view_wiki_tree"/>
        <field name="act_window_id" ref="action_page"/>
    </record>

    <record id="action_page_view_form" model="ir.actions.act_window.view">
        <field name="sequence" eval="5" />
        <field name="view_mode">form</field>
        <field name="view_id" ref="view_wiki_form"/>
        <field name="act_window_id" ref="action_page"/>
    </record>



   <menuitem id="menu_wiki"
        name="Pages"
        parent="knowledge.menu_document"
        sequence="20" />


    <menuitem id="menu_page"
        name="Pages"
        parent="menu_wiki"
        action="action_page"
        sequence="10" />


    <act_window
        id="action_related_page_create_menu"
        name="Create Menu"
        res_model="document.page.create.menu"
        target="new"
        view_type="form"
        view_mode="form"
        src_model="document.page"/>

</odoo>
