I am sharing a simple solution (most of the developers knows, but helpful for newbies like me) to show 2D barcode (or any type) on the delivery note.
Also through Jinja Format we can hide some serial number based on products. For example if you don’t want to show a product’s serial number create a custom field (check-box), and tag them. Find below code to print/not to print the tagged product’s serial number(s).
here is my delivery note output.
Header
<div class="print-heading">
<h2>Delivery Note</h2>
<br>
<div style="display:block">
<p>{{ doc.name }}</p>
<br>
<p>Date: {{ frappe.utils.get_datetime(doc.posting_date).strftime('%d-%m-%Y') }}</p>
<br /><img src="http://bwipjs-api.metafloor.com/?bcid=code128&text={{ doc.name }}&scaleX=1&scaleY=1" alt="barcode" height="10" width="200">
</div></div>
Serial Numbers (without any conditions)
<h6>Serial Number in 2D barcode format</h6>
{% for row in doc.items %}
<div style="content: "";display: table;clear: both;">
<div style="float: left;width: 50%;padding: 10px;">
<figure>
<img src="http://bwipjs-api.metafloor.com/?bcid=pdf417&text={{ row.serial_no }} " alt="barcode" align="middle" hspace="20">
<figcaption align="middle">{{ row.item_code }}</figcaption>
<figure>
</div>
</div>
{% endfor %}
Show serial number(s) Based on some conditions - Here I used tra (I created a check box called tra on product master)
<h6>Serial Number in 2D barcode format</h6>
{% set c = frappe.get_doc("Item", doc.item) %}
{{ c.tra or '0' }}
{% for row in doc.items if c.tra %}
{{ row.tra }}
<div style="content: "";display: table;clear: both;">
<div style="float: left;width: 50%;padding: 10px;">
<figure>
<img src="http://bwipjs-api.metafloor.com/?bcid=pdf417&text={{ row.serial_no }} " alt="barcode" align="middle" hspace="20">
<figcaption align="middle">{{ row.item_code }}</figcaption>
<figure>
</div>
</div>
{% endfor %}
on the line {% for row in doc.items if c.tra %} you can include IF NOT to toggle the checkbox.
thanks