<?xml version="1.0" encoding="utf-8"?>
<odoo>
        <record id="view_order_batch_form" model="ir.ui.view">
                <field name="name">sale.order.batch.form.product.min_max_qty</field>
                <field name="model">sale.order.batch</field>
                <field name="inherit_id" ref="sale_order_batch.view_order_batch_form"/>
                <field name="arch" type="xml">
                        <!-- Header buttons -->
                        <xpath expr="//button[@id='action_confirm_primary']" position="before">
                                <field name="has_qty_adjusted" invisible="1"/>
                                <field name="has_fillable_packages" invisible="1"/>
                                <button
                    name="action_fill_packages"
                    type="object"
                    class="btn-primary"
                    string="Fill Packages"
                    attrs="{'invisible': ['|', ('state', 'not in', ['in_progress']), ('has_fillable_packages', '=', False)]}"
                />
                        </xpath>
                        <xpath expr="//button[@id='action_confirm_primary']" position="attributes">
                                <attribute
                    name="attrs"
                >{'invisible': ['|', ('state', 'not in', ['in_progress']), ('has_fillable_packages', '=', True)]}</attribute>
                        </xpath>
                        <xpath expr="//button[@id='action_confirm_secondary']" position="attributes">
                                <attribute
                    name="attrs"
                >{"invisible": ["|", ["state", "not in", ["draft", "in_progress"]], ["has_fillable_packages", "=", False]]}</attribute>
                        </xpath>
                        <xpath expr="//button[@id='create_invoices']" position="before">
                                <button
                    name="action_restore_ordered_qty"
                    type="object"
                    string="Restore Ordered Qty"
                    attrs="{'invisible': ['|', ('state', '!=', 'in_progress'),('has_qty_adjusted', '=', False)]}"
                />
                        </xpath>
                        <!-- Fields -->
                        <xpath
                expr="//field[@name='sale_order_line_ids']/tree/field[@name='product_uom_qty']"
                position="before"
            >
                                <field name="product_uom_ordered_qty" optional="hide"/>
                        </xpath>
                        <xpath
                expr="//field[@name='sale_order_line_ids']/tree/field[@name='product_uom_qty']"
                position="after"
            >
                                <field name="product_uom_max_qty"/>
                        </xpath>
                        <xpath expr="//field[@name='product_ids']/tree" position="inside">
                                <field name="open_packaging_qty" invisiable="1"/>
                        </xpath>
                        <xpath expr="//field[@name='product_ids']/tree/field[@name='product_uom_qty']" position="after">
                                <field name="product_uom_max_qty"/>
                        </xpath>
                        <xpath expr="//field[@name='product_ids']/tree/field[@name='product_id']" position="attributes">
                                <attribute name="decoration-warning">(open_packaging_qty != 0)</attribute>
                        </xpath>
                </field>
        </record>
 </odoo>
