<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 Moduon Team S.L.
     License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) -->
<data>
    <record id="view_stock_move_line_operation_tree" model="ir.ui.view">
        <field name="name">Add product packaging qty done info</field>
        <field name="model">stock.move.line</field>
        <field name="inherit_id" ref="stock.view_stock_move_line_operation_tree" />
        <field name="arch" type="xml">
            <field name="reserved_uom_qty" position="before">
                <field
                    name="product_packaging_qty_reserved"
                    attrs="{'invisible': [('product_packaging_id', '=', False)]}"
                    groups="product.group_stock_packaging"
                />
            </field>
            <field name="qty_done" position="before">
                <field name="product_packaging_id" invisible="1" />
                <field
                    name="product_packaging_qty_done"
                    attrs="{'invisible': [('product_packaging_id', '=', False)]}"
                    groups="product.group_stock_packaging"
                />
            </field>
        </field>
    </record>

    <record id="view_stock_move_line_mobile_form_extension" model="ir.ui.view">
        <field name="name">Add product packaging qty done info</field>
        <field name="model">stock.move.line</field>
        <field name="inherit_id" ref="stock.view_move_line_mobile_form" />
        <field name="arch" type="xml">
            <xpath expr="//label[@for='reserved_uom_qty']" position="before">
                <label
                    for="product_packaging_qty_reserved"
                    attrs="{'invisible': [('state', '=', 'done')]}"
                    groups="product.group_stock_packaging"
                />
                <div
                    class="o_row"
                    attrs="{'invisible': [('state', '=', 'done')]}"
                    groups="product.group_stock_packaging"
                >
                    <field
                        name="product_packaging_qty_reserved"
                        attrs="{'invisible': [('product_packaging_id', '=', False)]}"
                    />
                    <field name="product_packaging_id" />
                </div>
            </xpath>
            <xpath expr="//label[@for='qty_done']" position="before">
                <label for="product_packaging_qty_done" />
                <div class="o_row">
                    <field
                        name="product_packaging_qty_done"
                        attrs="{'invisible': [('product_packaging_id', '=', False)]}"
                        groups="product.group_stock_packaging"
                    />
                    <field
                        name="product_packaging_id"
                        groups="product.group_stock_packaging"
                    />
                </div>
            </xpath>
        </field>
    </record>

    <record id="view_stock_move_line_detailed_operation_tree" model="ir.ui.view">
        <field name="name">Add product packaging qty done info</field>
        <field name="model">stock.move.line</field>
        <field
            name="inherit_id"
            ref="stock.view_stock_move_line_detailed_operation_tree"
        />
        <field name="arch" type="xml">
            <field name="reserved_uom_qty" position="before">
                <field
                    name="product_packaging_qty_reserved"
                    optional="show"
                    attrs="{'column_invisible': ['|',('parent.immediate_transfer', '=', True),('parent.picking_type_code','=','incoming')], 'invisible': [('product_packaging_id', '=', False)]}"
                    groups="product.group_stock_packaging"
                />
            </field>
            <field name="qty_done" position="before">
                <field
                    name="product_packaging_qty_done"
                    attrs="{'invisible': [('product_packaging_id', '=', False)]}"
                    groups="product.group_stock_packaging"
                />
                <field
                    name="product_packaging_id"
                    groups="product.group_stock_packaging"
                />
            </field>
        </field>
    </record>
    <record id="view_move_line_tree_detailed" model="ir.ui.view">
        <field name="name">Add product packaging qty done info</field>
        <field name="model">stock.move.line</field>
        <field name="inherit_id" ref="stock.view_move_line_tree_detailed" />
        <field name="arch" type="xml">
            <field name="qty_done" position="before">
                <field
                    name="product_packaging_qty_done"
                    attrs="{'invisible': [('product_packaging_id', '=', False)]}"
                    groups="product.group_stock_packaging"
                />
                <field
                    name="product_packaging_id"
                    groups="product.group_stock_packaging"
                />
            </field>
        </field>
    </record>
</data>
