<?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_stock_move_line_operation_tree" model="ir.ui.view">
        <field name="name">Stock Move Secondary Unit</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="secondary_uom_qty"
                    attrs="{'readonly': [('state', 'in', ('done', 'cancel')), ('is_locked', '=', True)]}"
                    force_save="1"
                    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)]"
                    attrs="{'readonly': [('state', '!=', 'draft'), ('id', '!=', False)]}"
                    options="{'no_create': True}"
                    groups="uom.group_uom"
                    optional="show"
                />
            </field>
        </field>
    </record>
    <record id="view_stock_move_line_detailed_operation_tree" model="ir.ui.view">
        <field name="name">stock.move.line.operations.tree</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="secondary_uom_qty"
                    attrs="{'readonly': [('state', 'in', ('done', 'cancel')), ('is_locked', '=', True)]}"
                    force_save="1"
                    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)]"
                    attrs="{'readonly': [('state', '!=', 'draft'), ('id', '!=', False)]}"
                    options="{'no_create': True}"
                    groups="uom.group_uom"
                    optional="show"
                />
            </field>
        </field>
    </record>
</odoo>
