When printing Lot/SNs barcodes, it's sometimes desired that we print a GS1 compliant datamatrix with the following info (when applicable): Product barcode, Lot/SN barcode, Best By Date, Expiration Date For flexibility, a setting has been added for when the GS1 datamatrix should print instead of 1D barcode. Note that datamatrix will automatically exclude invalid product barcodes (i.e. non-EAN compliant) and datamatrix size can vary based on amount of data in datamatrix (so size has been set to accomodate expected largest gs1 compliant datamatrix possible). If it appears that datamatrix cannot be created, then default to standard 1D barcode. Note that zpl printer has built in datamatrix creation command, so we can always assume they will print correctly. Part of Task: 2494740 Part-of: odoo/odoo#82389
48 lines
3.1 KiB
XML
48 lines
3.1 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<odoo>
|
|
<data>
|
|
<template id="report_lot_label">
|
|
<t t-call="web.basic_layout">
|
|
<t t-set='nRows' t-value='12'/>
|
|
<t t-set='nCols' t-value='4'/>
|
|
<div t-foreach="[docs[x:x + nRows * nCols] for x in range(0, len(docs), nRows * nCols)]" t-as="page_docs" class="o_label_sheet" t-att-style="'padding: 20mm 8mm'">
|
|
<table class="my-0 table table-sm table-borderless">
|
|
<t t-foreach="range(nRows)" t-as="row">
|
|
<tr>
|
|
<t t-foreach="range(nCols)" t-as="col">
|
|
<t t-set="barcode_index" t-value="(row * nCols + col)"/>
|
|
<t t-if="barcode_index < len(page_docs)">
|
|
<t t-set="o" t-value="page_docs[barcode_index]"/>
|
|
</t>
|
|
<t t-else="">
|
|
<t t-set="o" t-value="page_docs[0]"/>
|
|
</t>
|
|
<td t-att-style="barcode_index >= len(page_docs) and 'visibility:hidden'">
|
|
<div t-att-style="'position:relative; width:43mm; height:19mm; border: 1px solid %s;' % (o.env.user.company_id.primary_color or 'black')">
|
|
<div class="o_label_4x12" t-field="o.product_id.display_name"/>
|
|
<div class="o_label_4x12" name="lot_name">
|
|
LN/SN: <span t-field="o.name"/>
|
|
</div>
|
|
<t t-if="env.user.has_group('stock.group_stock_lot_print_gs1') and env['ir.actions.report'].datamatrix_available()">
|
|
<!-- ensure we clear barcode string when multi-record print -->
|
|
<t t-set="final_barcode" t-value="''"/>
|
|
<t t-if="o.product_id.valid_ean" t-set="final_barcode" t-value="'01' + '0' * (14 - len(o.product_id.barcode)) + o.product_id.barcode"/>
|
|
<t name="gs1_datamatrix_lot" t-if="o.product_id.tracking == 'lot'" t-set="final_barcode" t-value="(final_barcode or '') + '10' + o.name"/>
|
|
<t t-elif="o.product_id.tracking == 'serial'" t-set="final_barcode" t-value="(final_barcode or '') + '21' + o.name"/>
|
|
<div t-if="final_barcode" t-att-style="'position:absolute; right:.5px; bottom:.5px'" t-out="final_barcode" t-options="{'widget': 'barcode', 'symbology': 'DataMatrix', 'width': 45, 'height': 45}"/>
|
|
</t>
|
|
<t t-else="">
|
|
<div t-field="o.name" t-options="{'widget': 'barcode', 'img_style': 'width:100%; height:35%'}"/>
|
|
</t>
|
|
</div>
|
|
</td>
|
|
</t>
|
|
</tr>
|
|
</t>
|
|
</table>
|
|
</div>
|
|
</t>
|
|
</template>
|
|
</data>
|
|
</odoo>
|