<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
         <template id="report_asset_barcode">
            <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-if="asset.barcode">
                                <img alt="Barcode" t-if="len(asset.barcode) == 13" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('EAN13', quote_plus(asset.barcode or ''), 600, 150)" style="width:100%;height:4rem;"/>
                                <img alt="Barcode" t-elif="len(asset.barcode) == 8" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('EAN8', quote_plus(asset.barcode or ''), 600, 150)" style="width:100%;height:4rem;"/>
                                <img alt="Barcode" t-else="" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', quote_plus(asset.barcode or ''), 600, 150)" style="width:100%;height:4rem"/>
                                <span t-field="asset.barcode"/>
                            </t>
                            <t t-else=""><span class="text-muted">No barcode available</span></t>
                        </td>
                    </tr>
                </table>
            </div>
        </template>

        <template id="report_assetbarcode">
            <t t-call="web.basic_layout">
                <div class="page">
                    <t t-foreach="docs" t-as="asset">
                        <t t-call="exp_asset_base.report_asset_barcode">
                            <t t-set="asset" t-value="asset"/>
                        </t>
                    </t>
                </div>
            </t>
        </template>

        <record id="report_account_asset_barcode" model="ir.actions.report">
            <field name="name">Asset Barcode (PDF)</field>
            <field name="model">account.asset</field>
            <field name="report_type">qweb-pdf</field>
            <field name="report_name">exp_asset_base.report_assetbarcode</field>
            <field name="report_file">exp_asset_base.report_assetbarcode</field>
            <field name="print_report_name">'Assets barcode - %s' % (object.name)</field>
            <field name="binding_model_id" ref="exp_asset_base.model_account_asset"/>
            <field name="binding_type">report</field>
        </record>
    </data>
</odoo>
