<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017-20 ForgeFlow S.L.
     License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
    <template
        id="report_saleorder_document"
        inherit_id="sale.report_saleorder_document"
    >
        <xpath expr="//t[@t-set='display_discount']" position="after">
            <t
                t-set="display_discount_fixed"
                t-value="any([l.discount_fixed for l in doc.order_line])"
            />
        </xpath>
        <xpath expr="//th[@name='th_discount']/span" position="attributes">
            <attribute name="t-if">not display_discount_fixed</attribute>
        </xpath>

        <xpath expr="//th[@t-if='display_discount']/span" position="before">
            <t t-if="display_discount_fixed">
                <span>Discount Amount (%)</span>
            </t>
        </xpath>

        <span t-field="line.discount" position="before">
            <t t-if="display_discount_fixed">
                <span class="text-nowrap" t-field="line.discount_fixed" />
                <span class="text-nowrap"> (or</span>
            </t>
        </span>
        <span t-field="line.discount" position="after">
            <t t-if="display_discount_fixed">
                <span class="text-nowrap"> %)</span>
            </t>
        </span>
    </template>
</odoo>
