<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
    <!-- Category Views -->
    <record id="view_category_form" model="ir.ui.view">
        <field name="name">document.page.category.form</field>
        <field name="model">document.page</field>
        <field name="arch" type="xml">
            <form string="Category">
                <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'}"
                            />
                            <field
                                name="company_id"
                                groups="base.group_multi_company"
                            />
                        </group>
                        <group>
                            <field name="write_uid" groups="base.group_no_one" />
                            <field name="write_date" groups="base.group_no_one" />
                            <field name="menu_id" groups="base.group_no_one" />
                        </group>
                    </group>
                    <notebook>
                        <page string="Template" name="template">
                            <field
                                name="template"
                                placeholder="e.g. Once upon a time..."
                            />
                        </page>
                        <page string="Documents" name="documents">
                            <field
                                name="content"
                                widget="html"
                                class="oe_view_only"
                                options='{"safe": True}'
                                required="0"
                            />
                        </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_category_tree" model="ir.ui.view">
        <field name="name">document.page.category.tree</field>
        <field name="model">document.page</field>
        <field name="arch" type="xml">
            <tree string="Categories">
                <field name="name" />
                <field name="parent_id" />
                <field name="create_uid" invisible="1" />
                <field name="write_uid" />
                <field name="write_date" />
                <field name="company_id" groups="base.group_multi_company" />
            </tree>
        </field>
    </record>
    <record id="view_document_category_filter" model="ir.ui.view">
        <field name="name">document.page.category.search</field>
        <field name="model">document.page</field>
        <field name="arch" type="xml">
            <search string="Document Category">
                <field
                    name="name"
                    string="Content"
                    filter_domain="['|', ('name','ilike',self), ('template','ilike',self)]"
                />
                <field name="parent_id" />
                <field name="create_uid" />
                <field name="content_uid" />
                <field name="company_id" groups="base.group_multi_company" />
                <group expand="0" string="Group By...">
                    <filter
                        name="group_by_category"
                        string="Category"
                        context="{'group_by':'parent_id'}"
                    />
                    <filter
                        name="group_by_author"
                        string="Author"
                        context="{'group_by':'create_uid'}"
                    />
                    <filter
                        name="group_by_last_contributor"
                        string="Last Contributor"
                        context="{'group_by':'content_uid'}"
                    />
                </group>
            </search>
        </field>
    </record>
    <!-- Category Action -->
    <record id="action_category" model="ir.actions.act_window">
        <field name="name">Category</field>
        <field name="res_model">document.page</field>
        <field name="domain">[('type','=','category')]</field>
        <field name="context">{'default_type': 'category'}</field>
        <field name="view_mode">tree,form</field>
        <field name="view_id" ref="view_category_tree" />
        <field name="search_view_id" ref="view_document_category_filter" />
    </record>
    <record id="action_category_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_category_tree" />
        <field name="act_window_id" ref="action_category" />
    </record>
    <record id="action_category_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_category_form" />
        <field name="act_window_id" ref="action_category" />
    </record>
    <menuitem
        id="menu_category"
        parent="menu_wiki"
        name="Categories"
        action="action_category"
        sequence="20"
    />
</odoo>
