How to Create Barcodes in Odoo 18

October 21, 2025 by
admin


                                                                                                                 



How to Create Barcodes in Odoo 18 
Introduction:
Barcodes play a crucial role in modern business operations by boosting speed, accuracy, and efficiency across various processes such as inventory tracking, sales, purchasing, and logistics. By automating data capture, they minimize manual errors and help organizations maintain better control over their workflows.
With Odoo 18, businesses gain a flexible platform to integrate barcode functionality directly into their applications. This makes it possible to design and customize barcode generation according to specific needs—whether it’s for sales, warehouse management, or product labeling. 


Some key benefits of using barcodes include:
  • Process automation – speeding up operations like stock transfers or order confirmations.

  • Error reduction – minimizing mistakes caused by manual data entry.

  • Operational efficiency – improving transaction speed and saving employee time.

  • Improved traceability – enabling quick identification and tracking of records across the system.

In this guide, we’ll look at how you can generate and print barcodes dynamically in Odoo 18. The example will use the Sale Order model, where we create a unique barcode based on the order date and reference. The same method can easily be extended to other models or adapted to follow your own business logic for barcode creation.


Step 1: Add a Barcode Field by Extending the Model
The first step is to inherit the target model and introduce a dedicated field for storing barcodes. This field will hold values that are automatically generated whenever a new record is created, ensuring each entry gets its own unique barcode.

Key Points:
  •  The barcode field is a Char field to store the generated barcode.
  •  The create method ensures the barcode is automatically generated when a new Sale Order is created.
  •  The logic combines the date_order and name fields to create a unique identifier. You can modify this logic as needed.
Step 2: Display the Barcode on the Form View
Next, we customize the Sale Order form view to include the newly created barcode field. By extending the existing view, the barcode becomes visible to users directly within the interface.

The inherit_id specifies the base form view of the Sale Order model that we are extending.
The xpath expression is used to insert the barcode field right after the payment_term_id field. You can adjust the xpath target if you prefer to display the barcode in a different location within the form.


Step 3: Create an Action for Printing Barcodes
To print barcodes, you need to define a report action that links to a QWeb template. This report action is used to generate PDF documents containing the barcodes.


Explanation:
Make sure to replace your_module with the actual name of your custom module.
The report_name and report_file fields define which QWeb template will be used when generating the report.
Step 4: Create a QWeb Template for the Barcode PDF
This template determines how the barcode will appear in the generated PDF, including its layout and styling. Odoo’s native barcode rendering functionality is used to render the barcode as an image within the report.


Explanation:
The <img> tag is used to dynamically render the barcode as an image, leveraging Odoo’s built-in barcode generation engine.
Final Output

In the Sale Order form, the newly added barcode field now holds the generated barcode. To print it, go to Actions → Print → Sale Order Barcode.


File Structure Overview
Before diving into the implementation, it’s helpful to understand how the module is organized. A clear file structure ensures that your barcode functionality is easy to maintain and extend. Here’s a typical layout for the barcode feature in Odoo 18:
  • models/ – Contains the Python files where you define or extend your models (e.g., adding the barcode field).

  • views/ – Includes XML files for form views, tree views, and other UI customizations.

  • report/ – Holds the QWeb templates and report definitions used to generate barcode PDFs.

  • __init__.py-This  files ensure that Odoo loads your Python modules properly when the module is installed or updated.

  • __manifest__.py – The module descriptor that tells Odoo about your module and its dependencies.

This structure provides a clean separation of concerns and makes it easier to scale the feature or reuse it in other models.



Conclusion
Barcodes play a key role in streamlining and speeding up business workflows, making them a vital feature in today’s systems. In this guide, we demonstrated how to dynamically generate and print barcodes in Odoo 18 using the Sale Order model as an example. The same approach can be applied to any other model, helping you improve accuracy and operational efficiency throughout your organization.
Whether you’re managing stock, processing sales, or coordinating shipments, barcodes offer a practical and scalable way to simplify your processes. Use this tutorial as a starting point to build a customized barcode solution that fits the specific needs of your business.
If you are looking for an ERP implementation partner with diverse industry experience feel free to contact us. We have proven track record of successful implementations across various sectors including Odoo for Manufacturing, Odoo for Trading, Odoo for FMCG, Odoo for Oil & Gas, Odoo for Diary, Odoo for Pharma, Odoo for Cosmetic Clinic, Odoo for Contracting Companies, Odoo for HVAC, Odoo for Logistics, Odoo for Automobile, Odoo for Laundry, Odoo for Field Service, Odoo for E-Commerce & many more
ZestyBeanz offers Developer / Consultant outsourcing programs, Chat with us in Whatsapp and Hire Odoo Developers, Mobile Application Developers, Consultants.
#OdooKerala #OdooKochi #OdooTrivandrum #OdooERP #ProjectManagement #OdooVansales #HireOdooDeveloper