<?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_template_property_form" model="ir.ui.view">
        <field name="name">Product template Secondary Unit</field>
        <field name="model">product.template</field>
        <field name="inherit_id" ref="stock.view_template_property_form" />
        <field name="groups_id" eval="[(4, ref('stock.group_stock_user'))]" />
        <field name="arch" type="xml">
            <xpath expr="//group[@name='inventory']" position="inside">
                <group string="Secondary unit">
                    <field
                        name="stock_secondary_uom_id"
                        options="{'no_create': True}"
                    />
                </group>
            </xpath>
        </field>
    </record>
    <record id="product_template_form_view_procurement_button" model="ir.ui.view">
        <field name="model">product.template</field>
        <field
            name="inherit_id"
            ref="stock.product_template_form_view_procurement_button"
        />
        <field name="groups_id" eval="[(4, ref('stock.group_stock_user'))]" />
        <field name="arch" type="xml">
            <xpath expr="//button[@name='action_open_quants']" position="after">
                <button
                    type="object"
                    name="action_open_quants"
                    attrs="{'invisible':[('type', '!=', 'product')]}"
                    class="oe_stat_button"
                    icon="fa-building-o"
                >
                    <div class="o_form_field o_stat_info">
                        <span class="o_stat_value">
                            <field
                                name="secondary_unit_qty_available"
                                widget="statinfo"
                                nolabel="1"
                            />
                        </span>
                        <span class="o_stat_text">
                            <field name="stock_secondary_uom_id" readonly="1" />
                        </span>
                    </div>
                </button>
            </xpath>
        </field>
    </record>
    <record id="product_form_view_procurement_button" model="ir.ui.view">
        <field name="model">product.product</field>
        <field name="inherit_id" ref="stock.product_form_view_procurement_button" />
        <field name="groups_id" eval="[(4, ref('stock.group_stock_user'))]" />
        <field name="arch" type="xml">
            <xpath expr="//button[@name='action_open_quants']" position="after">
                <button
                    type="object"
                    name="action_open_quants"
                    attrs="{'invisible':[('type', '!=', 'product')]}"
                    class="oe_stat_button"
                    icon="fa-building-o"
                >
                    <div class="o_form_field o_stat_info">
                        <span class="o_stat_value">
                            <field
                                name="secondary_unit_qty_available"
                                widget="statinfo"
                                nolabel="1"
                            />
                        </span>
                        <span class="o_stat_text">
                            <field name="stock_secondary_uom_id" />
                        </span>
                    </div>
                </button>
            </xpath>
        </field>
    </record>
    <record id="product_template_tree_view" model="ir.ui.view">
        <field name="model">product.template</field>
        <field name="inherit_id" ref="product.product_template_tree_view" />
        <field name="groups_id" eval="[(4, ref('stock.group_stock_user'))]" />
        <field name="arch" type="xml">
            <xpath expr="//field[@name='uom_id']" position="after">
                <field name="secondary_unit_qty_available" />
                <field
                    name="stock_secondary_uom_id"
                    options="{'no_open': True, 'no_create': True}"
                />
            </xpath>
        </field>
    </record>
    <record id="product_product_tree_view" model="ir.ui.view">
        <field name="model">product.product</field>
        <field name="inherit_id" ref="product.product_product_tree_view" />
        <field name="groups_id" eval="[(4, ref('stock.group_stock_user'))]" />
        <field name="arch" type="xml">
            <xpath expr="//field[@name='uom_id']" position="after">
                <field name="secondary_unit_qty_available" />
                <field
                    name="stock_secondary_uom_id"
                    options="{'no_open': True, 'no_create': True}"
                />
            </xpath>
        </field>
    </record>
</odoo>
