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

    <template id="sale_order_portal_content_inherit_sale_quotation_builder" name="Order Design" inherit_id="sale.sale_order_portal_content">
        <xpath expr="//div[@id='informations']" position="after">
            <div t-field="sale_order.website_description" class="oe_no_empty"/>
            <t t-set="product_tmpl_ids" t-value="[]"/>
            <t t-foreach="sale_order.order_line" t-as="line">
                <t t-if="line.product_id.product_tmpl_id.id not in product_tmpl_ids">
                    <t t-set="product_tmpl_ids" t-value="product_tmpl_ids + [line.product_id.product_tmpl_id.id]"/>
                    <a t-att-id="line.id"/>
                    <div t-att-class="'oe_no_empty' if line.website_description else 'oe_no_empty d-print-none'" t-field="line.website_description"/>
                </t>
            </t>
        </xpath>
    </template>

    <!-- Template to edit the quotation template with the website editor -->
    <template id="so_template" name="SO Template">
        <t t-call="website.layout">
            <body>
                <div class="container o_sale_order">
                    <div class="row mt16">
                        <div class="col-lg-9 ml-auto">
                            <div class="row mb8">
                                <div t-ignore="true" class="css_editable_mode_hidden offset-lg-11">
                                  <a role="button" class="btn btn-info d-print-none" t-att-href="'/web#return_label=Website&amp;model=%s&amp;id=%s&amp;action=%s&amp;view_type=form' % (template._name, template.id, request.env.ref('sale_management.sale_order_template_action').id)">Back</a>
                                </div>
                            </div>
                            <div class="alert alert-info alert-dismissable" t-ignore="True" role="status">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close">&amp;times;</button>
                                <p>
                                    <strong>Template Header:</strong> this content
                                    will appear on all quotations using this
                                    template.
                                </p>
                                <p class="text-muted">
                                    Titles with style <i>Heading 1</i> and
                                    <i>Heading 2</i> will be used to generate the
                                    table of content automatically.
                                </p>
                            </div>
                            <div id="template_introduction" t-field="template.website_description" class="oe_no_empty"/>
                            <t t-set="product_tmpl_ids" t-value="[]"/>
                            <t t-foreach="template.sale_order_template_line_ids" t-as="line">
                                <t t-if="line.product_id.product_tmpl_id.id not in product_tmpl_ids">
                                    <t t-set="product_tmpl_ids" t-value="product_tmpl_ids + [line.product_id.product_tmpl_id.id]"/>
                                    <div class="alert alert-info alert-dismissable mt16" t-ignore="True" role="status">
                                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">&amp;times;</button>
                                        Product: <strong t-esc="line.product_id.name"/>:
                                        this content will appear on the quotation only if this
                                        product is put on the quote.
                                    </div>
                                    <div t-field="line.website_description" class="oe_no_empty"/>
                                </t>
                            </t>
                            <t t-set="product_tmpl_ids" t-value="[]"/>
                            <t t-foreach="template.sale_order_template_option_ids" t-as="option_line">
                                <t t-if="option_line.product_id.product_tmpl_id.id not in product_tmpl_ids">
                                    <t t-set="product_tmpl_ids" t-value="product_tmpl_ids + [option_line.product_id.product_tmpl_id.id]"/>
                                    <div class="alert alert-info alert-dismissable mt16" t-ignore="True" role="status">
                                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">&amp;times;</button>
                                        Optional Product: <strong t-esc="option_line.product_id.name"/>:
                                        this content will appear on the quotation only if this
                                        product is used in the quote.
                                    </div>
                                    <div t-field="option_line.website_description" class="oe_no_empty"/>
                                </t>
                            </t>
                            <section id="terms" class="container" t-if="template.note">
                                <h1 t-ignore="True">Terms &amp; Conditions</h1>
                                <p t-field="template.note"/>
                            </section>
                        </div>
                    </div>
                </div>
            </body>
        </t>
    </template>

    <template id="brand_promotion" inherit_id="website.brand_promotion">
        <xpath expr="//div[hasclass('o_brand_promotion')]" position="replace">
            <div class="o_brand_promotion">
                Powered by <a target="_blank" class="badge badge-danger" href="http://www.odoo.com/page/website-builder">Odoo</a>,
                an awesome <a target="_blank" href="http://www.odoo.com/page/crm">Open Source CRM</a>.
            </div>
        </xpath>
    </template>

</odoo>
