<?xml version="1.0"?>
<data name="Order Options" inherit_id="sale.sale_order_portal_content">

        <xpath expr="//section[@id='details']//t[@t-set='display_discount']" position="after">
            <t t-set="display_remove" t-value="sale_order._can_be_edited_on_portal() and any(line._can_be_edited_on_portal() for line in sale_order.order_line)"/>
        </xpath>

        <xpath expr="//section[@id='details']//table[@id='sales_order_table']/thead/tr" position="inside">
            <!-- add blank Tr in thead for layout conciseness -->
            <th t-if="display_remove">
            </th>
        </xpath>

        <xpath expr="//section[@id='details']//t[@name='product_line_row']" position="inside">
            <td class="text-center" t-if="display_remove">
                <a t-if="line._can_be_edited_on_portal()" t-att-data-line-id="line.id" t-att-data-unlink="True" href="#" class="mb8 js_update_line_json d-print-none" aria-label="Remove" title="Remove">
                    <span class="fa fa-trash-o"/>
                </a>
            </td>
        </xpath>

        <xpath expr="//section[@id='signature']" position="after">
            <t t-if="sale_order._can_be_edited_on_portal() and any((not option.is_present) for option in sale_order.sale_order_option_ids)">
                <section>
                    <h3>Options</h3>
                    <t t-set="display_discount" t-value="True in [option.discount &gt; 0 for option in sale_order.sale_order_option_ids]"/>
                    <table class="table table-sm" name="sale_order_options_table">
                        <thead>
                            <tr>
                                <th class="text-start" name="th_option_product_name">Product</th>
                                <th t-if="display_discount" class="text-end" name="th_option_discount">Disc.%
                                </th>
                                <th class="text-end" name="th_option_unit_price">Unit Price</th>
                                <th t-if="sale_order._can_be_edited_on_portal() and report_type == 'html'" name="th_option_add_button"/>
                            </tr>
                        </thead>
                        <tbody>
                            <tr t-foreach="sale_order.sale_order_option_ids" t-as="option">
                                <t t-if="not option.is_present">
                                    <td name="td_option_product_name">
                                        <div t-field="option.name"/>
                                    </td>
                                    <td t-if="display_discount" class="text-end" name="td_option_discount">
                                        <strong t-if="option.discount" class="text-info">
                                            <t t-out="((option.discount % 1) and '%s' or '%d') % option.discount"/>%
                                        </strong>
                                    </td>
                                    <td name="td_option_unit_price">
                                        <strong class="text-end">
                                            <div t-field="option.price_unit" t-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: sale_order.currency_id}" t-att-style="option.discount and 'text-decoration: line-through' or None" t-att-class="option.discount and 'text-danger' or None"/>
                                            <div t-if="option.discount">
                                                <t t-out="(1-option.discount / 100.0) * option.price_unit" t-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: sale_order.currency_id}"/>
                                            </div>
                                        </strong>
                                    </td>
                                    <td class="text-end" t-if="sale_order._can_be_edited_on_portal() and report_type == 'html'" name="td_option_add_button">
                                        <a t-att-data-option-id="option.id" href="#" class="mb8 js_add_optional_products d-print-none" aria-label="Add to cart" title="Add to cart">
                                            <span class="btn btn-secondary">Add to order</span>
                                        </a>
                                    </td>
                                </t>
                            </tr>
                        </tbody>
                    </table>
                </section>
            </t>
        </xpath>

        <xpath expr="//section[@id='details']//div[@id='quote_qty']" position="replace">
            <t t-if="line._can_be_edited_on_portal()">
                <div class="input-group js_quantity_container pull-right">

                    <span class="d-print-none input-group-text d-none d-md-inline-block">
                        <a t-att-data-line-id="line.id" t-att-data-remove="True" href="#" class="js_update_line_json" aria-label="Remove one" title="Remove one">
                            <span class="fa fa-minus"/>
                        </a>
                    </span>
                    <!-- TODO add uom in this case too -->
                    <input type="text" class="js_quantity form-control" t-att-data-line-id="line.id" t-att-value="line.product_uom_qty"/>
                    <span class="d-print-none input-group-text d-none d-md-inline-block">
                        <a t-att-data-line-id="line.id" href="#" class="js_update_line_json" aria-label="Add one" title="Add one">
                            <span class="fa fa-plus"/>
                        </a>
                    </span>
                </div>
            </t>
            <t t-else="">
                <span t-field="line.product_uom_qty"/>
                <span t-field="line.product_uom"/>
            </t>
        </xpath>

    </data>

