<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record id="package_level_form_view" model="ir.ui.view">
        <field name="name">Package Level</field>
        <field name="model">stock.package_level</field>
        <field name="arch" type="xml">
            <form>
                <header>
                    <field name="state" widget="statusbar" statusbar_visible="draft,confirmed,assigned,done" />
                </header>
                <group>
                    <field name="picking_id" invisible="1"/>
                    <field name="picking_source_location" invisible="1"/>
                    <field name="show_lots_m2o" invisible="1"/>
                    <field name="show_lots_text" invisible="1"/>
                    <group>
                        <field name="package_id"/>
                        <field name="location_id" groups="stock.group_stock_multi_locations"/>
                        <field name="location_dest_id" groups="stock.group_stock_multi_locations"/>
                        <field name="is_done"/>
                    </group>
                    <field name="move_ids" attrs="{'invisible': [('state', 'in', ('new', 'draft', 'assigned', 'done'))]}">
                        <tree>
                            <field name="product_id"/>
                            <field name="product_uom_qty"/>
                            <field name="quantity_done"/>
                            <field name="product_uom" groups="uom.group_uom"/>
                            <field name="state" invisible="1"/>
                        </tree>
                    </field>
                    <field name="move_line_ids" attrs="{'invisible': [('state', 'in', ('draft', 'confirmed', 'cancel'))]}">
                        <tree>
                            <field name="product_id"/>
                            <field name="lot_id" attrs="{'column_invisible': [('parent.show_lots_m2o', '=', False)]}" groups="stock.group_production_lot"/>
                            <field name="lot_name" attrs="{'column_invisible': [('parent.show_lots_text', '=', False)]}" groups="stock.group_production_lot"/>
                            <field name="owner_id" groups="stock.group_tracking_owner"/>
                            <field name="product_uom_qty"/>
                            <field name="qty_done"/>
                            <field name="product_uom_id" options="{'no_open': True, 'no_create': True}" attrs="{'readonly': [('product_uom_qty', '!=', 0.0)]}" string="Unit of Measure" groups="uom.group_uom"/>
                            <field name="state" invisible="1"/>
                        </tree>
                    </field>
                </group>
            </form>
        </field>
    </record>

    <record id="package_level_tree_view_picking" model="ir.ui.view">
        <field name="name">Package Level Tree Picking</field>
        <field name="model">stock.package_level</field>
        <field name="priority">1000</field>
        <field name="arch" type="xml">
            <tree editable="bottom" decoration-muted="state == 'done'">
                <field name="is_fresh_package" invisible="1"/>
                <field name="package_id" attrs="{'readonly': [('state', 'in', ('confirmed', 'assigned', 'done', 'cancel'))]}" domain="[('location_id', 'child_of', parent.location_id)]" options="{'no_create': True}"/>
                <field name="location_id" attrs="{'column_invisible': [('parent.picking_type_code', '=', 'incoming')]}" groups="stock.group_stock_multi_locations"/>
                <field name="location_dest_id" domain="[('id', 'child_of', parent.location_dest_id)]" attrs="{'column_invisible': [('parent.picking_type_code', '=', 'outgoing')]}" groups="stock.group_stock_multi_locations"/>
                <field name="state"/>
                <field name="is_done" attrs="{'readonly': ['|', ('parent.state', 'in', ('draft', 'new', 'done')), ('is_fresh_package', '=', True)]}"/>
            </tree>
        </field>
    </record>
</odoo>
