<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <record id="hr_equipment_request_view_search" model="ir.ui.view">
        <field name="model">maintenance.request</field>
        <field name="inherit_id" ref="maintenance.hr_equipment_request_view_search" />
        <field name="arch" type="xml">
            <xpath expr="//filter[@name='high_priority']" position="after">
                <separator groups="stock.group_stock_user" />
                <filter
                    string="Allow Consumptions"
                    name="allow_consumptions"
                    domain="[('allow_consumptions', '=', True)]"
                    groups="stock.group_stock_user"
                />
            </xpath>
        </field>
    </record>

    <record id="hr_equipment_request_view_tree" model="ir.ui.view">
        <field name="model">maintenance.request</field>
        <field name="inherit_id" ref="maintenance.hr_equipment_request_view_tree" />
        <field name="arch" type="xml">
            <xpath expr="//field[@name='category_id']" position="after">
                <field name="allow_consumptions" groups="stock.group_stock_user" />
            </xpath>
        </field>
    </record>

    <record id="equipment_request_view_form" model="ir.ui.view">
        <field name="model">maintenance.request</field>
        <field name="inherit_id" ref="base_maintenance.equipment_request_view_form" />
        <field name="arch" type="xml">
            <xpath expr="//div[@name='button_box']" position="inside">
                <field
                    name="allow_consumptions"
                    invisible="1"
                    groups="stock.group_stock_user"
                />
                <button
                    class="oe_stat_button"
                    type="object"
                    name="action_view_stock_picking_ids"
                    icon="fa-ticket"
                    invisible="allow_consumptions == False"
                    groups="stock.group_stock_user"
                >
                    <div class="o_form_field o_stat_info">
                        <span class="o_stat_text">Picking list</span>
                    </div>
                </button>

                <button
                    class="oe_stat_button"
                    type="object"
                    name="action_view_stock_move_ids"
                    icon="fa-arrows-v"
                    invisible="allow_consumptions == False"
                    groups="stock.group_stock_user"
                >
                    <div class="o_form_field o_stat_info">
                        <span class="o_stat_text">Stock Moves</span>
                    </div>
                </button>

                <button
                    class="oe_stat_button"
                    type="object"
                    name="action_view_stock_move_line_ids"
                    icon="fa-arrows-v"
                    invisible="allow_consumptions == False"
                    groups="stock.group_stock_user"
                >
                    <div class="o_form_field o_stat_info">
                        <span class="o_stat_text">Product Moves</span>
                    </div>
                </button>
            </xpath>
        </field>
    </record>
</odoo>
