Barcode And QR Code On Odoo V9
April 23, 2016
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:
- Log in to Azure DevOps and navigate to your project.
- sudo pip install reportlab --upgrade
Step 2: Load fonts by following below mentioned steps:
- Log in to Azure DevOps and navigate to your project.
- Go to path /usr/lib/python2.7/dist-packages/reportlab
- Log in to Azure DevOps and navigate to your project.
- Create a new folder named fonts.
- Log in to Azure DevOps and navigate to your project.
- Download fonts using from here: http://www.reportlab.com/ftp/fonts/pfbfer.zip
- Log in to Azure DevOps and navigate to your project.
- Extract this zip file in: /usr/lib/python2.7/dist-packages/reportlab/fonts
- Log in to Azure DevOps and navigate to your project.
- 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&value=%s&width=%s&height=%s' % ('Code128', o.name, 50, 50)" style="width:50px;height:50px;"/>
For QRCode:
<img t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('QR', o.name, 50, 50)" style="width:50px;height:50px;"/>
Step 4: Restart server, upgrade related module from database and print report.
For professional paid support, you may contact us at [email protected] .