<?xml version="1.0" encoding="utf-8" ?>
<odoo>
    <template id="report_blanketorder_document">
        <t t-call="web.external_layout">
            <t t-set="doc" t-value="doc.with_context({'lang':doc.partner_id.lang})" />
            <div class="page">
                <div class="oe_structure" />
                <div class="row">
                    <div class="col-xs-6">
                        <div
                            t-field="doc.partner_id"
                            t-options='{"widget": "contact", "fields": ["address", "name", "phone", "fax"], "no_marker": True, "phone_icons": True}'
                        />
                        <p t-if="doc.partner_id.vat">VAT: <span
                                t-field="doc.partner_id.vat"
                            /></p>
                    </div>
                </div>
                <h2>
                    <span>Blanket Order # </span>
                    <span t-field="doc.name" />
                </h2>
                <div class="row mt32 mb32" id="informations">
                    <div class="col-xs-3">
                        <strong>Validity Date:</strong>
                        <p t-field="doc.validity_date" />
                    </div>
                    <div t-if="doc.payment_term_id" class="col-xs-3">
                        <strong>Payment Terms:</strong>
                        <p t-field="doc.payment_term_id" />
                    </div>
                    <div t-if="doc.user_id.name" class="col-xs-3">
                        <strong>Purchase person:</strong>
                        <p t-field="doc.user_id" />
                    </div>
                    <div t-if="doc.currency_id" class="col-xs-3">
                        <strong>Currency:</strong>
                        <p t-field="doc.currency_id" />
                    </div>
                </div>
                <table class="table table-condensed">
                    <thead>
                        <tr>
                            <th>Product</th>
                            <th class="text-right">Unit Price</th>
                            <th class="text-center">Scheduled Date</th>
                            <th class="text-right">Original Qty</th>
                            <th class="text-right">Amount</th>
                        </tr>
                    </thead>
                    <tbody class="purchase_tbody">
                        <t t-foreach="doc.line_ids" t-as="l">
                            <tr>
                                <td name="td_name" class="text-left">
                                    <span t-field="l.product_id" />
                                </td>
                                <td class="text-right">
                                    <span t-field="l.price_unit" />
                                </td>
                                <td class="text-center">
                                    <span t-field="l.date_schedule" />
                                </td>
                                <td class="text-right">
                                    <span t-field="l.original_uom_qty" />
                                    <span
                                        t-field="l.product_uom"
                                        groups="uom.group_uom"
                                    />
                                </td>
                                <td class="text-right">
                                    <span
                                        t-field="l.price_subtotal"
                                        t-options='{"widget": "monetary", "display_currency": l.currency_id}'
                                    />
                                </td>
                            </tr>
                        </t>
                    </tbody>
                </table>
                <div id="total" class="row justify-content-end">
                    <div class="col-4">
                        <table class="table table-condensed">
                            <tr class="border-black">
                                <td>
                                    <strong>Subtotal</strong>
                                </td>
                                <td class="text-right">
                                    <span
                                        t-field="doc.amount_untaxed"
                                        t-options='{"widget": "monetary", "display_currency": doc.currency_id}'
                                    />
                                </td>
                            </tr>
                            <tr>
                                <td>Taxes</td>
                                <td class="text-right">
                                    <span
                                        t-field="doc.amount_tax"
                                        t-options='{"widget": "monetary", "display_currency": doc.currency_id}'
                                    />
                                </td>
                            </tr>
                            <tr class="border-black">
                                <td>
                                    <strong>Total</strong>
                                </td>
                                <td class="text-right">
                                    <span
                                        t-field="doc.amount_total"
                                        t-options='{"widget": "monetary", "display_currency": doc.currency_id}'
                                    />
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <p t-field="doc.note" />
                <div class="oe_structure" />
            </div>
        </t>
    </template>
    <template id="report_blanketorder">
        <t t-call="web.html_container">
            <t t-foreach="docs" t-as="doc">
                <t
                    t-call="purchase_blanket_order.report_blanketorder_document"
                    t-lang="doc.partner_id.lang"
                />
            </t>
        </t>
    </template>
</odoo>
