<?xml version="1.0" encoding="UTF-8" ?>
<odoo>

    <template id="sale_order_portal_template_inherit" inherit_id="sale.sale_order_portal_template">
        <!-- LEFT COLUMN ACTIONS -->
        <xpath expr="//li[1]" position="replace">
            <t t-set="sale_order_exceptions" t-value="sale_order._check_sale_order_exceptions()"/>
            <li class="list-group-item flex-grow-1">
                <a t-if="sale_order.has_to_be_signed(True) and not sale_order_exceptions"
                   role="button" class="btn btn-primary btn-block mb8"
                   data-toggle="modal"
                   data-target="#modalaccept"
                   href="#">
                    <i class="fa fa-check"/>
                    <t t-if="sale_order.has_to_be_paid(True)"> Sign &amp; Pay</t>
                    <t t-else=""> Accept &amp; Sign</t>
                </a>
                <a t-elif="sale_order.has_to_be_paid(True) and not sale_order_exceptions"
                   role="button"
                   id="o_sale_portal_paynow"
                   data-toggle="modal"
                   data-target="#modalaccept"
                   href="#"
                   t-att-class="'btn-block mb8 %s' % ('btn btn-light' if sale_order.transaction_ids else 'btn btn-primary')">
                    <i class="fa fa-check"/>
                    <t t-if="not sale_order.signature">Accept &amp; Pay</t>
                    <t t-else="">Pay Now</t>
                </a>
                <t t-if="sale_order_exceptions">
                    <t t-foreach="sale_order_exceptions" t-as="exception">
                        <a href="#discussion" role="button" class="btn btn-danger btn-block mb8"
                           style="max-width: 180px;">
                            <i class="fa fa-warning"/>
                            <span t-esc="exception['description']"/>
                        </a>
                    </t>
                </t>
            </li>
        </xpath>

        <!-- BOTTOM ACTIONS -->
        <xpath expr="//div[@t-if='sale_order.has_to_be_signed(True) or sale_order.has_to_be_paid(True)']" position="replace">
            <div t-if="sale_order.has_to_be_signed(True) or sale_order.has_to_be_paid(True)"
                 class="row justify-content-center text-center d-print-none pt-1 pb-4">
                <t t-set="sale_order_exceptions" t-value="sale_order._check_sale_order_exceptions()"/>
                <t t-if="sale_order.has_to_be_signed(True)">
                    <div t-if="not sale_order_exceptions" class="col-sm-auto mt8">
                        <a role="button" class="btn btn-primary" data-toggle="modal"
                           data-target="#modalaccept" href="#">
                            <i class="fa fa-check"/>
                            <t t-if="sale_order.has_to_be_paid(True)"> Sign &amp; Pay</t>
                            <t t-else=""> Accept &amp; Sign</t>
                        </a>
                    </div>
                    <div class="col-sm-auto mt8">
                        <a role="button" class="btn btn-secondary" href="#discussion">
                            <i class="fa fa-comment"/> Feedback</a>
                    </div>
                    <div class="col-sm-auto mt8">
                        <a role="button" class="btn btn-danger" data-toggle="modal"
                           data-target="#modaldecline" href="#"> <i class="fa fa-times"/> Reject</a>
                    </div>
                </t>
                <div t-elif="sale_order.has_to_be_paid(True) and not sale_order_exceptions" class="col-sm-auto mt8">
                    <a role="button" data-toggle="modal" data-target="#modalaccept" href="#"
                       t-att-class="'%s' % ('btn btn-light' if sale_order.transaction_ids else 'btn btn-primary')">
                        <i class="fa fa-check"/> <t t-if="not sale_order.signature">Accept &amp; Pay</t>
                        <t t-else="">Pay Now</t>
                    </a>
                </div>
            </div>
        </xpath>
    </template>

</odoo>
