Guide on Adding Barcode in Qweb PDF Report
Barcodes are an essential element in business management, helping you a way to encode information into machine-readable formats made up of numbers and varying-width lines. In Odoo18, barcodes are typically used in modules such as Inventory and POS to efficiently specify and identify product templates. So here we go, in this post we’ll walk you through how to add barcode in Qweb PDF report in Odoo, and a completely closer look at how you can easily integrate barcodes into your Qweb PDF reports
Odoo helps you to create custom barcodes using any string format, including both numbers and characters. Barcode nomenclatures help set the rules for your barcodes, and these can be configured under the Barcode Nomenclature menu in Inventory > Configuration.
Available Barcode Formats In Odoo18
Odoo supports several barcode formats, including:
- CODE128: A high-density linear barcode format.
- EAN13: A standard 13-digit barcode.
- EAN8: A standard 8-digit barcode.
- QR: For QR codes.
To include the barcode, do the way shown in the following code, here I added an Image tag to an XML template that I produced in Partner View. If we want to print a barcode in a Qweb report, we should embed it inside the tag.

<div style="margin: 20px auto;":
<span t-field="docs.barcode" t-options="{'widget': 'barcode', 'width': 600, 'height': 150, 'img_style': 'width:170px; height:50px;'}"></span>
An Overview of Attributes and Purpose
t-field=”doc.barcode”
- The t-field attribute binds the barcode field of the doc record.
- Using the barcode widget, the doc.barcode value will encoded and displayed as a barcode.
t-options
This attribute provides additional customization for rendering the barcode.
Key Options
- widget: Specifies the rendering widget. Here, barcode tells Odoo to use the barcode widget for this field.
- width and height: Define the dimensions of the barcode in pixels (600px wide by 150px tall).
- img_style: Customizes the appearance of the generated barcode image.
- width:170px; height:50px;: Specifies the visible size of the barcode image (this overrides the width and height options for display purposes).
- margin: auto;: Centers the barcode horizontally within its container.
- display: block;: Makes the barcode a block element, ensuring a more consistent and organized layout.

Take a look at the image below to see how barcodes are created within the customer form view.

You can see in the template above the partner name, barcode, and barcode string i added, As a result, the barcode image below will be generated.

Adding barcode in Qweb PDF report can peak your product management and increase accuracy. Odoo18 makes the integration of barcodes easy. For guidance on barcode customization nor Custom ERP solutions, Transines Solutions is here for you!
Our consulting services will help identify the best barcode solution for your needs and business objectives. Connect with us for the Best Odoo Barcode Solutions and advance your business with us.
"Automate Your Business with our Customized Odoo ERP Solutions"
"Get a Cost Estimate for Your ERP Project, Absolutely FREE!"
Get a Free Quote


