Introduction to QR Codes in Odoo
QR (Quick Response) codes are widely used in modern business systems to encode and share data in a fast and efficient way. These two-dimensional barcodes can store order details, URLs, identifiers, or payment information, and they can be scanned easily by mobile devices. In an ERP environment such as Odoo, QR codes can significantly improve efficiency by reducing manual input, improving data accuracy, and enabling quick information retrieval. For example, scanning a QR code on a Sales Order could instantly display its details, or a QR code on a delivery slip could simplify product tracking in the warehouse.
In Odoo 19, you can generate QR codes by creating a custom module that extends any model (e.g., Sale Orders, Invoices, Purchase Orders). The module adds a binary field to store the QR code image, a compute method to dynamically generate it using the qrcode Python library, and an XML view to display it in the form view.
This allows you to instantly generate scannable QR codes for business documents inside Odoo, improving accuracy and efficiency.
General Approach for QR Code Integration
The process of implementing QR code generation in Odoo follows a structured pattern that can be adapted for any business object:
- Library Setup: Install a Python library (such as qrcode) that will handle QR code generation.
- Model Extension: Add a new Binary field to the target model where the QR code image will be stored.
- Compute Method: Implement a method that dynamically generates QR codes using record data and stores them as Base64 images.
- Dependencies Tracking: Use Odoo’s @api.depends decorator to ensure the QR code automatically updates when relevant fields change.
- View Integration: Extend the Odoo views (form or reports) to display the QR code field as an image.
- Packaging: Bundle the logic into a module with proper manifest definitions and dependencies.
This generic pattern ensures the QR code generator can be applied universally across Odoo, regardless of the module.
Steps to Generate QR Codes in Odoo 19
General Approach for QR Code IntegrationTo demonstrate the implementation, we will extend the sale.order model to generate a QR code containing the Sale Order reference and its total amount.
Install Required Python Library
The QR code functionality relies on the Python qrcode library. Install it in your Odoo environment with:

Create a Custom Module Structure
The module must follow Odoo’s standard directory format. A minimal structure looks like this:

This ensures the module is discoverable and maintainable.
Extend the Model with QR Code Field
The core functionality lies in extending the chosen model. In our example, we extend sale.order to add a QR code field and a compute method:
Python code:
from odoo import models, fields, api
import base64
import io
import qrcode
class SaleOrder(models.Model):
_inherit = 'sale.order'
qr_code = fields.Binary("QR Code", compute='_generate_qr_code', store=True)
@api.depends('name', 'amount_total')
def _generate_qr_code(self):
for rec in self:
if qrcode and base64:
qr = qrcode.QRCode(
version=1, error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
qr.add_data("Sale No : ")
qr.add_data(rec.name or '')
qr.add_data(", Customer : ")
qr.add_data(rec.partner_id.name or '')
qr.add_data(", Amount Total : ")
qr.add_data(str(rec.amount_total) or '')
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
temp = io.BytesIO()
img.save(temp, format="PNG")
qr_image = base64.b64encode(temp.getvalue())
rec.update({'qr_code': qr_image})
This compute method ensures that whenever the Sale Order name or total amount changes, the QR code is regenerated to reflect updated data. The QR code itself is stored as a Base64 string in the binary field, which Odoo can render as an image.
Modify the Form View to Display the QR Code
To display the QR code, the Sale Order form view is extended with XML:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_order_form_inherit_qr_code" model="ir.ui.view">
<field name="name">sale.order.form.inherit.qr.code</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='payment_term_id']" position="after">
<field name="qr_code" widget="image" class="oe_avatar" readonly="1"/>
</xpath>
</field>
</record>
</odoo>
This places the QR code image field immediately after the Payment Terms field in the Sale Order form. Similar logic can be applied to invoices, purchase orders, or any other form.

When you scan the QR code, it displays key details from the sales order, such as:
Sale No: S00003, Customer: Gemini Furniture, Amount Total: $140.00
This example highlights how Odoo 18 can automatically generate QR codes for sales orders, making it easier for customers to view their order information quickly by just scanning the code.
Adapting to Other Models
Although Sale Orders were used in this example, the same approach works for any Odoo model:
- Invoices (account.move): QR codes can include invoice number, total amount, and due date.
- Purchase Orders (purchase.order): QR codes can include vendor, PO number, and amount.
- Inventory Transfers (stock.picking): QR codes can contain transfer references and source/destination locations.
- Products (product.template): QR codes can include product name, internal reference, or a product page URL.
To implement QR codes in these cases, simply:
- Replace the target model (_inherit) with the desired one.
- Adjust the compute method to generate the required data string.
- Extend the corresponding view to display the QR code.
To read more about How to Generate a QR Code in Odoo 18, refer to our blog How to Generate a QR Code in Odoo 18.
FAQs
Q1: Can I generate QR codes for Invoices or Products in Odoo 19?
Yes. The same logic works for any model—just extend account.move for invoices or product.template for products.
Q2: Do I need to install extra dependencies?
Only the Python qrcode library is required. Install it via pip install qrcode.
Q3: Will the QR code update automatically?
Yes. Using @api.depends, the QR code regenerates whenever relevant fields (e.g., order name or amount) change
Q4: Can QR codes be added to PDF reports like invoices?
Yes. You can extend report templates in Odoo to display the QR code field in PDF documents.