<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2018 Tecnativa - Sergio Teruel
     License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
    <record id="view_picking_form" model="ir.ui.view">
        <field name="name">Stock Picking Secondary Unit</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_form" />
        <field name="arch" type="xml">
            <xpath
                expr="//field[@name='move_ids_without_package']/tree/field[@name='product_uom_qty']"
                position="before"
            >
                <field
                    name="secondary_uom_qty"
                    attrs="{'column_invisible': [('parent.immediate_transfer', '=', True)], 'readonly': ['|', ('is_initial_demand_editable', '=', False), '&amp;', '&amp;', ('show_operations', '=', True), ('is_locked', '=', True), ('is_initial_demand_editable', '=', False)]}"
                    groups="uom.group_uom"
                    optional="show"
                />
                <field
                    name="secondary_uom_id"
                    domain="product_id and ['|', ('product_id', '=', product_id),
                                '&amp;', ('product_tmpl_id.product_variant_ids', 'in', [product_id]),
                                         ('product_id', '=', False)] or [(0, '=', 1)]"
                    options="{'no_create': True}"
                    attrs="{'column_invisible': [('parent.immediate_transfer', '=', True)], 'readonly': ['|', ('is_initial_demand_editable', '=', False), '&amp;', '&amp;', ('show_operations', '=', True), ('is_locked', '=', True), ('is_initial_demand_editable', '=', False)]}"
                    groups="uom.group_uom"
                    optional="show"
                />
            </xpath>
            <xpath
                expr="//field[@name='move_ids_without_package']/form//field[@name='product_uom_qty']"
                position="before"
            >
                <field
                    name="secondary_uom_qty"
                    attrs="{'invisible': [('parent.immediate_transfer', '=', True)], 'readonly': [('is_initial_demand_editable', '=', False)]}"
                    groups="uom.group_uom"
                />
                <field
                    name="secondary_uom_id"
                    domain="product_id and ['|', ('product_id', '=', product_id),
                                '&amp;', ('product_tmpl_id.product_variant_ids', 'in', [product_id]),
                                         ('product_id', '=', False)] or [(0, '=', 1)]"
                    options="{'no_create': True}"
                    attrs="{'invisible': [('parent.immediate_transfer', '=', True)], 'readonly': [('is_initial_demand_editable', '=', False)]}"
                    groups="uom.group_uom"
                />
            </xpath>
        </field>
    </record>
</odoo>
