<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_pricelist">
    <t t-call="web.html_container">
        <t t-call="web.internal_layout">
            <div class="page">
                <h2>Price List</h2>

                <div class="row mt32 mb32">
                    <div class="col-3">
                        <strong>Price List Name</strong>:<br/>
                        <span t-esc="data['pricelist'].name"/>
                    </div>
                    <div class="col-3">
                        <strong>Currency</strong>:<br/>
                        <span t-esc="data['pricelist'].currency_id.name"/>
                    </div>
                    <div class="col-3">
                        <strong>Print date</strong>:<br/>
                        <t t-esc="datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')"/>
                    </div>
                </div>

                <table class="table table-sm">
                    <thead>
                        <tr>
                            <th>
                                <strong>Description</strong>
                            </th>
                            <t t-foreach="data['quantities']" t-as="quantity">
                                <th><strong t-esc="'%s units' % quantity"/></th>
                            </t>
                        </tr>
                    </thead>
                    <tbody>
                        <t t-foreach="data['categories_data']" t-as="categ_data">
                            <tr>
                                <td colspan="100">
                                    <strong t-esc="categ_data['category'].name"/>
                                </td>
                            </tr>
                            <tr t-foreach="categ_data['products']" t-as="product">
                                <td>
                                    <t t-if="product.code">
                                        [<span t-esc="product.code"/>]
                                    </t> 
                                    <span t-esc="product.name"/>
                                    <span t-foreach="product.attribute_value_ids" t-as="attribute_value">
                                        <span t-if="attribute_value_first">-</span>
                                        <span t-if="not attribute_value_last" t-esc="attribute_value.name+','"/>
                                        <span t-else="" t-esc="attribute_value.name"/>
                                    </span>
                                </td>
                                <t t-foreach="data['quantities']" t-as="quantity">
                                    <td><strong t-esc="categ_data['prices'][product.id][quantity]"
                                                t-esc-options="{
                                                    'widget': 'monetary',
                                                    'display_currency': data['pricelist'].currency_id}"/>
                                    </td>
                                </t>
                            </tr>
                        </t>
                    </tbody>
                </table>
            </div>
        </t>
    </t>
</template>
</odoo>
