<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <record id="view_stock_reserve_rule_form" model="ir.ui.view">
        <field name="name">stock.reserve.rule.form</field>
        <field name="model">stock.reserve.rule</field>
        <field name="arch" type="xml">
            <form string="Reservation Rule">
                <sheet>
                    <div class="oe_button_box" name="button_box">
                    </div>
                    <widget
                        name="web_ribbon"
                        title="Archived"
                        bg_color="bg-danger"
                        attrs="{'invisible': [('active', '=', True)]}"
                    />
                    <label for="name" class="oe_edit_only" />
                    <h1>
                        <field name="name" />
                    </h1>
                    <group string="Rule Applicability" name="configuration">
                        <group>
                            <field name="active" invisible="1" />
                            <field name="location_id" />
                            <field
                                name="picking_type_ids"
                                widget="many2many_tags"
                                options="{'no_create': 1}"
                            />
                            <field name="sequence" />
                        </group>
                        <group>
                            <field
                                name="rule_domain"
                                widget="domain"
                                options="{'model': 'stock.move', 'in_dialog': true}"
                            />
                            <field
                                name="company_id"
                                groups="base.group_multi_company"
                            />
                        </group>
                    </group>
                    <group string="Removal Rules" name="rule" col="1">
                        <field name="rule_removal_ids" nolabel="1">
                            <tree string="Removal Rules">
                                <field name="sequence" widget="handle" />
                                <field name="name" />
                                <field name="location_id" />
                                <field name="removal_strategy" />
                            </tree>
                            <form string="Removal Rule">
                                <group>
                                    <field name="name" />
                                    <field
                                        name="location_id"
                                        domain="[('id', 'child_of', parent.location_id)]"
                                    />
                                    <field name="removal_strategy" />
                                    <field
                                        name="packaging_type_ids"
                                        widget="many2many_tags"
                                        attrs="{'invisible': [('removal_strategy', '!=', 'packaging')]}"
                                    />
                                    <field
                                        name="quant_domain"
                                        widget="domain"
                                        options="{'model': 'stock.quant', 'in_dialog': true}"
                                    />
                                </group>
                            </form>
                        </field>
                    </group>
                </sheet>
            </form>
        </field>
    </record>
    <record id="view_stock_reserve_rule_search" model="ir.ui.view">
        <field name="name">stock.reserve.rule.search</field>
        <field name="model">stock.reserve.rule</field>
        <field name="arch" type="xml">
            <search string="Reservation Rule">
                <field name="name" />
                <field name="location_id" />
                <field name="picking_type_ids" />
                <separator />
                <filter
                    string="Archived"
                    name="inactive"
                    domain="[('active','=',False)]"
                />
            </search>
        </field>
    </record>
    <record id="view_stock_reserve_rule_tree" model="ir.ui.view">
        <field name="name">stock.reserve.rule</field>
        <field name="model">stock.reserve.rule</field>
        <field name="arch" type="xml">
            <tree string="Reservation Rule">
                <field name="sequence" widget="handle" />
                <field name="name" />
                <field name="location_id" />
                <field
                    name="picking_type_ids"
                    widget="many2many_tags"
                    options="{'no_create': 1}"
                />
                <field name="rule_domain" />
            </tree>
        </field>
    </record>
    <record id="action_stock_reserve_rule" model="ir.actions.act_window">
        <field name="name">Reservation Rules</field>
        <field name="res_model">stock.reserve.rule</field>
        <field name="type">ir.actions.act_window</field>
        <field name="view_id" ref="view_stock_reserve_rule_tree" />
        <field name="search_view_id" ref="view_stock_reserve_rule_search" />
        <field name="context" />
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                Add a Reservation Rule
            </p>
        </field>
    </record>
    <menuitem
        action="action_stock_reserve_rule"
        id="menu_stock_reserve_rule"
        parent="stock.menu_warehouse_config"
        sequence="10"
    />
</odoo>
