<?xml version="1.0" encoding="utf-8" ?>
<!--
  Copyright 2019-2024 Akretion France (http://www.akretion.com/)
  @author Alexis de Lattre <alexis.delattre@akretion.com>
  License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>


<!-- I don't know why the form view of product.packaging in the delivery
     module has "<field name="inherit_id" eval="False"/>"
    instead of a standard inherit of product.product_packaging_form_view -->
<record id="product_packaging_delivery_form" model="ir.ui.view">
    <field name="name">stock_packaging_usability_pp.product.packaging.form</field>
    <field name="model">product.packaging</field>
    <field name="inherit_id" ref="delivery.product_packaging_delivery_form" />
    <field name="arch" type="xml">
        <field name="package_carrier_type" position="after">
            <field name="packaging_type" />
            <field name="active" invisible="1" />
        </field>
        <label for="max_weight" position="before">
            <label for="weight" />
            <div class="o_row" name="weight">
                <field name="weight" />
                <span><field name="weight_uom_name" /></span>
            </div>
        </label>
        <label for="name" position="before">
            <widget
                    name="web_ribbon"
                    title="Archived"
                    bg_color="bg-danger"
                    attrs="{'invisible': [('active', '=', True)]}"
                />
        </label>
    </field>
</record>

<record id="product_packaging_delivery_tree" model="ir.ui.view">
    <field name="name">stock_packaging_usability_pp.product.packaging.tree</field>
    <field name="model">product.packaging</field>
    <field name="inherit_id" ref="delivery.product_packaging_delivery_tree" />
    <field name="arch" type="xml">
        <field name="name" position="after">
            <field name="packaging_type" optional="show" />
        </field>
        <field name="max_weight" position="before">
            <field name="weight" optional="show" />
        </field>
    </field>
</record>

<!-- There is no native serch view for product.packaging -->
<record id="product_packaging_search" model="ir.ui.view">
    <field name="name">product.packaging.search</field>
    <field name="model">product.packaging</field>
    <field name="arch" type="xml">
        <search>
            <field name="name" />
            <separator />
            <filter
                    string="Archived"
                    name="inactive"
                    domain="[('active', '=', False)]"
                />
            <group name="groupby">
                <filter
                        name="packaging_type_groupby"
                        string="Packaging Type"
                        context="{'group_by': 'packaging_type'}"
                    />
            </group>
        </search>
    </field>
</record>


</odoo>
