<?xml version="1.0" encoding="utf-8"?>

<!--
    Copyright 2018 ACSONE SA/NV.
    License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->

<odoo>

    <record id="view_order_form" model="ir.ui.view">
        <field name="name">sale.order.form (in
            product_contract_variable_quantity)
        </field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='order_line']/form//label[@for='name']"
                   position="before">
                <group col="4">
                    <field name="qty_type"
                           attrs="{'required': [('is_contract', '=', True)], 'invisible': [('is_contract', '=', False)]}"/>
                    <field name="qty_formula_id"
                           attrs="{'required': [('qty_type', '=', 'variable')], 'invisible': [('qty_type', '!=', 'variable')]}"
                    />
                </group>
            </xpath>
            <xpath expr="//field[@name='order_line']/tree//field[@name='product_uom_qty']"
                   position="after">
                <field name="qty_type"
                       attrs="{'column_invisible': [('parent.is_contract', '=', False)]}"/>
                <field name="qty_formula_id"
                       attrs="{'column_invisible': [('parent.is_contract', '=', False)]}"/>
            </xpath>
        </field>
    </record>

</odoo>
