<?xml version="1.0"?>
<odoo>

    <record id="sale_order_form_quote" model="ir.ui.view">
        <field name="name">sale.order.form.inherit.sale_management</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
            <page name="order_lines" position="after">
                <page string="Optional Products"
                    name="optional_products"
                    invisible="state not in ['draft', 'sent']">
                    <field name="sale_order_option_ids" mode="tree,kanban" readonly="state in ['cancel', 'sale']">
                        <form string="Optional Products">
                            <group>
                                <field name="product_id"
                                    domain="[('sale_ok', '=', True), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/>
                                <field name="name"/>
                                <field name="quantity"/>
                                <field name="product_uom_category_id" invisible="1"/>
                                <field name="uom_id" groups="uom.group_uom"/>
                                <field name="price_unit"/>
                                <field name="discount" groups="product.group_discount_per_so_line"/>
                                <field name="is_present" />
                            </group>
                        </form>
                        <kanban class="o_kanban_mobile">
                            <field name="product_id"/>
                            <field name="quantity"/>
                            <field name="uom_id" groups="uom.group_uom"/>
                            <field name="price_unit"/>
                            <field name="is_present" />
                            <templates>
                                <t t-name="kanban-box">
                                    <div class="oe_kanban_card oe_kanban_global_click">
                                        <div class="row">
                                            <div class="col-10">
                                                <strong>
                                                    <span>
                                                        <t t-out="record.product_id.value"/>
                                                    </span>
                                                </strong>
                                            </div>
                                            <div class="col-2">
                                                <button name="button_add_to_order"
                                                    class="btn btn-link oe_link fa fa-shopping-cart"
                                                    title="Add to order lines"
                                                    type="object"
                                                    invisible="is_present"/>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-12 text-muted">
                                                <span>
                                                    Quantity:
                                                    <t t-out="record.quantity.value"/>
                                                    <t t-out="record.uom_id.value" groups="uom.group_uom"/>
                                                </span>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-12 text-muted">
                                                <span>
                                                    Unit Price:
                                                    <t t-out="record.price_unit.value"/>
                                                </span>
                                            </div>
                                        </div>
                                    </div>
                                </t>
                            </templates>
                        </kanban>
                        <tree string="Sales Quotation Template Lines"
                            editable="bottom"
                            decoration-success="is_present == True">
                            <control>
                                <create name="add_product_control" string="Add a product"/>
                            </control>
                            <field name="sequence" widget="handle"/>
                            <field name="product_id"
                                domain="[('sale_ok', '=', True), '|', ('company_id', '=', False), ('company_id', '=', parent.company_id)]"/>
                            <field name="name" optional="show"/>
                            <field name="quantity"/>
                            <field name="uom_id" string="UoM" groups="uom.group_uom" optional="show"/>
                            <field name="product_uom_category_id" column_invisible="True"/>
                            <field name="price_unit"/>
                            <field name="discount"
                                string="Disc.%"
                                groups="product.group_discount_per_so_line"
                                optional="show"/>
                            <field name="is_present" column_invisible="True" />
                            <button name="button_add_to_order"
                                type="object"
                                class="oe_link"
                                icon="fa-shopping-cart"
                                title="Add to order lines"
                                invisible="is_present"/>
                        </tree>
                    </field>
                </page>
            </page>

            <field name="partner_shipping_id" position="after">
                <field name="sale_order_template_id"
                    options="{'no_create': True}"
                    groups="sale_management.group_sale_order_template"
                 readonly="state in ['cancel', 'sale']"/>
            </field>
        </field>
    </record>

</odoo>
