We used cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it. What For?

« Back to Blogs

Barcode and QR code on Odoo v9

Barcode is a machine-readable code in the form of numbers and a pattern of parallel lines of varying widths, printed on a commodity and used especially for stock control. In other terms we can say Barcodes are images returned by a controller and can easily be embedded in reports. 
 
QR code (abbreviated from Quick Response Code) is the trademark for a type of matrix barcode (or two-dimensional barcode). A QR code uses four standardized encoding modes (numeric, alphanumeric, byte/binary, and kanji) to efficiently store data.
 
To generate a barcode or QR code you have to first configure your system by following steps:
 
Step 1: Update reportlab using following command:
  • sudo pip install reportlab --upgrade
Step 2: Load fonts by following below mentioned steps:
  • Go to path /usr/lib/python2.7/dist-packages/reportlab
  • Create a new folder named fonts.
  • Download fonts using from here: http://www.reportlab.com/ftp/fonts/pfbfer.zip
  • Extract this zip file in: /usr/lib/python2.7/dist-packages/reportlab/fonts
  • Use this command to unzip it: unzip pfbfer.zip -d /usr/lib/python2.7/dist-packages/reportlab/fonts
Step 3: Now go to report template xml file in which you have created template for the report and just write this tag at the place where you want to display code in report: 
 
  • For Barcode:
<img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', o.name, 50, 50)" style="width:50px;height:50px;"/> 
 
  • For QRCode:
<img t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('QR', o.name, 50, 50)" style="width:50px;height:50px;"/>
 
Step 4: Restart server, upgrade related module from database and print report.
contact-us Request a callback WhatsApp