ERPNext Conference 2019* Blog

How to print barcode label



I need print item barcode on the label format like


Add barcode type in Version 11

Use Barcode type field and a custom print format


could you eleborate


Did you get it @farhanayyaz1




@farhanayyaz1 :frowning:


dear anyone has an update on this.c


Any one?
I am trying to achieve the same.
Can anyone guide on custom script?

Current Plan is to pull item details on a printable area.( printable area can be the size of the label)
Using the Purchase receipt/ material receipt item data.

I would like to know how to loop the print format area for each item row?


Finally we made a custom JS Barcode script and a custom Print format for 1.5 X 1 Inch barcode labels.

Used it in Stock entry(material receipt) and Purchase Receipt. With batch number and expiry.
Also made a print checkbox in item row. If ticked then it will only print the item row checked to print.

Sample below:


Above image has the following:
Font used Sans serif with 10, and 8 size
Company Name.
Item Name
Item Code
Batch Number in Barcode Font.
Expiry Date and Price.

Everything can be customized thanks to frappe framework.

Load a Javascript in /print

Hello @fkardame @JoEz

How to set the value of the barcode field type from javascript and python?


Set the value of the barcode field type

What u mean by type? Like code128A or upc?
I didnt get ur question


Thank you @fkardame
I mean how to set the value of the barcode field?
In other words: if the field type is barcode (I mean by type is the type of the field which might be Int, Float, Text, Table, HTML, barcode, … etc), so how to set the value of this barcode field.

I need to set the value from javascript or from python, and not from user interface. I know that I can enter it directly from the keyboard, but I need to set the value from js or py.


Hello @fkardame
As example:

frm.set_value('discount_amount', 100);

Is used to set the value of the field name discount_amount to 0, but if we use the same code to set the value of the barcode field then it will not work. So how can we set the value of the barcode field using javascript and python?

I need to set the value of the barcode to be 1122334455, how?



Any help?


Hello @JoEz
Can you please help in this if possible?
Because you suggested to use barcode field type, so I expect that you have experience in this (if you can help please).
If not possible, I hope to advise me that it is not possible and then we can find another way.
But normally, it should be possible to set the value of any field !


Try using Value field as {{ doc.barcode }} and field type as Data

<svg class="barcode"
			jsbarcode-value="{{ doc.barcode}}"/></svg></br> <script src=""></script>

This is the script we use in print format for barcode


Thank you @fkardame

<script src=""></script>

Can you please help, if I need to download JsBarcode.all.min.js and place it locally, for example if I placed it under the custom application of the following path:
home/frappe/frappe/apps/collection/collection/public/js/JsBarcode.all.min.js so how it will be the link to be used for src?

Anyway, this is for printing and thank you @fkardame

But have you tried to use the barcode field type which is existed in erpnext?
I hope that @JoEz or @pratu16x7 can help in advising how to set the value field of the barcode field because they are the owner andn contributor for this field type from this topic:



Have a look at:


Hello @JoEz
What you mentioned is about the options and not about the value.
I am asking how to set the value of the barcode from javascript and not the options.

In other words:
If I have a data field that has the following value: “11223344” and I need to set the value of the barcode field to this data field from javascript, what is the js code to be used?

Is it frm.set_value('barcode_field_name', data_field_name); ?
I tried set_value and it did not work.

Please advice.


Could you please share your script, or info on how to add additional button and wire up script to it.