<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
    <template id="report_simple_asset_number">
        <div style="width: 32%; display: inline-table; height: 10rem;">
            <table class="table table-bordered mb-0" style="border: 2px solid black;">
                <tr>
                    <th class="table-active text-left" style="height: 4rem;">
                        <strong t-field="asset.display_name" />
                    </th>
                </tr>
                <tr>
                    <td class="text-center align-middle" style="height: 6rem;">
                        <t t-set="profile" t-value="asset.profile_id" />
                        <t t-if="asset.number">
                            <t t-if="profile.barcode_type == 'barcode'">
                                <img
                                    alt="Barcode"
                                    t-if="len(asset.number) == 13"
                                    t-att-src="'/report/barcode/?barcode_type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('EAN13', quote_plus(asset.number or ''), profile.barcode_width, profile.barcode_height)"
                                    style="display: block; margin: 0 auto;"
                                />
                                <img
                                    alt="Barcode"
                                    t-elif="len(asset.number) == 8"
                                    t-att-src="'/report/barcode/?barcode_type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('EAN8', quote_plus(asset.number or ''), profile.barcode_width, profile.barcode_height)"
                                    style="display: block; margin: 0 auto;"
                                />
                                <img
                                    alt="Barcode"
                                    t-else=""
                                    t-att-src="'/report/barcode/?barcode_type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', quote_plus(asset.number or ''), profile.barcode_width, profile.barcode_height)"
                                    style="display: block; margin: 0 auto;"
                                />
                            </t>
                            <t t-elif="profile.barcode_type == 'qr'">
                                <img
                                    alt="QRcode"
                                    t-att-src="'/report/barcode/?barcode_type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('QR', quote_plus(asset.number or ''), profile.barcode_width, profile.barcode_width)"
                                    style="display: block; margin: 0 auto;"
                                />
                            </t>
                                <span t-field="asset.number" />
                        </t>
                        <t t-else="">
                            <span class="text-muted">No number available</span>
                        </t>
                    </td>
                </tr>
            </table>
        </div>
    </template>

    <template id="report_asset_number">
        <t t-call="web.basic_layout">
            <div class="page">
                <t t-foreach="docs" t-as="asset">
                    <t t-call="account_asset_number.report_simple_asset_number" />
                </t>
            </div>
        </t>
    </template>
    <record id="report_account_asset_number" model="ir.actions.report">
        <field name="name">Asset Number (PDF)</field>
        <field name="model">account.asset</field>
        <field name="report_type">qweb-pdf</field>
        <field name="report_name">account_asset_number.report_asset_number</field>
        <field name="report_file">account_asset_number.report_asset_number</field>
        <field name="print_report_name">'Asset Number - %s' % (object.name)</field>
        <field
            name="binding_model_id"
            ref="account_asset_management.model_account_asset"
        />
        <field name="binding_type">report</field>
    </record>
</odoo>
