<?xml version="1.0" encoding="UTF-8" ?>
<!--

    Copyright 2017-2019 MuK IT GmbH
    Copyright 2024 Subteno - Timothée Vannier (https://www.subteno.com).
    License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

  -->
<odoo>
    <record id="view_dms_category_search" model="ir.ui.view">
        <field name="name">dms_category.search</field>
        <field name="model">dms.category</field>
        <field name="arch" type="xml">
            <search string="Categories">
                <field
                    name="name"
                    filter_domain="['|', ('name', 'ilike', self), ('parent_id', 'child_of', raw_value)]"
                />
                <filter
                    string="All"
                    name="all"
                    domain="['|', ('active', '=', False), ('active', '=', True)]"
                />
            </search>
        </field>
    </record>
    <record id="view_dms_category_tree" model="ir.ui.view">
        <field name="name">dms_category.list</field>
        <field name="model">dms.category</field>
        <field name="arch" type="xml">
            <list>
                <field name="name" />
                <field name="parent_id" />
                <field name="tag_ids" />
            </list>
        </field>
    </record>
    <record id="view_dms_category_form" model="ir.ui.view">
        <field name="name">dms_category.form</field>
        <field name="model">dms.category</field>
        <field name="arch" type="xml">
            <form string="Category">
                <sheet>
                    <widget
                        name="web_ribbon"
                        title="Archived"
                        bg_color="bg-danger"
                        invisible="active"
                    />
                    <div class="oe_button_box" name="button_box" />
                    <div class="oe_title">
                        <label for="name" class="oe_edit_only" />
                        <h1>
                            <field name="name" placeholder="Invoices" />
                            <field name="active" invisible="1" />
                        </h1>
                    </div>
                    <group>
                        <group>
                            <field name="parent_id" />
                        </group>
                        <group>
                            <field name="count_categories" string="Subcategories" />
                        </group>
                    </group>
                    <group>
                        <group>
                            <field name="count_tags" string="Tags" />
                        </group>
                        <group>
                            <field name="count_files" string="Files" />
                            <field name="count_directories" string="Directories" />
                        </group>
                    </group>
                    <notebook>
                        <page string="Tags">
                            <field
                                name="tag_ids"
                                mode="kanban"
                                context="{'default_category_id': id}"
                            />
                        </page>
                        <page string="Subcategories">
                            <field
                                name="child_category_ids"
                                widget="one2many"
                                mode="list"
                                context="{'default_parent_id': id}"
                            />
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>
    <record id="action_dms_category" model="ir.actions.act_window">
        <field name="name">Categories</field>
        <field name="res_model">dms.category</field>
        <field name="view_mode">list,form</field>
        <field name="context">{'search_default_all': 1}</field>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                Create a new Category.
            </p>
            <p>
                Categories are used to categorize Documents.
            </p>
        </field>
    </record>
</odoo>
