Published in


How to Generate a QR Code in Odoo 14

Qr code in odoo 14

A QR code is a quick response code that looks similar to barcodes. Which is frequently used day by day for tracking information. It consists of many black squares arranged in a square grid with a white background where we can embed the data which is readable by an imaging device.

In odoo, QR Code plays a vital role in reporting, data analysis, etc… It is quickly readable and helps to store an enormous amount of data. It can be used to track product Information, stock moves, invoices, sale,s and purchase details in Odoo.

This Blog describes how to generate a QR code in odoo 14. Here it illustrates an example of a QR code for a particular invoice. QR code reads the details of an invoice order with the sequence, customer, and amount details.

QR code generation works with a python library qr code, which helps for the QR code image generation. For that, first, we need to install the package using the command in the terminal Pip3 install QRcode.

Above it illustrates the code example of creating a QR code in invoices which depicts the invoice details like payment reference, customer and Invoice date, etc…

In the inherited python file, imported the QRcode and base64 library for an image if and simply added a compute field of binary type for QRcode.

The corresponding XML File is as follows

Version: It is a parameter is an integer from 1 to 40 that controls the size of the QR code (the smallest, version 1, is a 21 * 21 Matrix)

Error_correction: The parameter controls the error correction used for the QR code.

Box_size: This parameter controls how many pixels on each box are needed to accumulate

Border: It controls the number of the boxes and which thick the border should be(default=4)

.add_data parameter can be used to add data to the QRcode, In this example creating the QRcode of an invoice company_name, reference of the payment, customer and salesperson details. And using all parameters the QR will make an image in the make_image function.

The corresponding image can be saved as either SVG or PNG format; here it is saved as PNG format and then encoded the value and assigned to a particular value in the field in the invoice.

When the QRcode is scanned the output obtained as

Using this method we can generate a QR code that stores data from different records in Odoo 14.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cybrosys Technologies

We are Odoo Gold Partners standing par excellence in Odoo implementation, customization and allied services.