Simplifying Barcode Generation in Odoo
Manually assigning barcodes to products can be tedious and error-prone. Fortunately, Odoo's automation rules allow you to generate sequential barcodes easily without writing complex code. In this guide, we’ll walk you through how to set up automation rules to generate barcodes dynamically whenever a new product is created.
Why Use Automation Rules for Barcode Generation?
Automating barcode generation offers several benefits:
- Eliminates manual entry – No need to type or assign barcodes manually.
- Ensures unique and sequential barcodes – Prevents duplicates.
- Saves time – Barcodes are automatically assigned when products are created.
- Reduces human errors – No risk of miskeyed barcodes.
Steps to Automate Barcode Generation
Let’s dive into the setup process. Follow these steps to configure automation rules in Odoo:
1. Enable Developer Mode
Before configuring automation rules, you must enable Developer Mode in Odoo. Here’s how:
- Navigate to Settings.
- Scroll down and click Activate Developer Mode.
Enabling Developer Mode unlocks advanced features, including the ability to create automation rules.
2. Create a New Sequence for Barcodes
Next, you’ll create a sequence to generate unique barcodes automatically. Here’s how to set it up:
- Go to Settings > Technical > Sequences & Identifiers > Sequences.
- Click Create and configure the sequence:
- Name: Product Barcode Sequence
- Code: product.barcode.sequence (used in automation rules)
- Prefix: PRD- (e.g., PRD-000001, PRD-000002, etc.)
- Sequence Size: 6 (determines the barcode length)
- Step: 1 (increments the barcode number by 1 each time)
- Save the sequence.
Example

3. Create an Automation Rule for Barcode Generation
Now, define the automation rule that assigns a barcode whenever a new product is created. Follow these steps:
Navigate to Automated Actions
- Go to Settings > Technical > Automation > Automated Actions.
- Click Create to define a new rule.
Configure and Save the Automation Rule
Fill in the following details:
- Name: Assign Barcode to New Products
- Model: Product Template (applies to products)
- Trigger Condition: On Save
- Action Type: Execute Python


- Click Save to activate the automation rule.
Automating barcode generation in Odoo is a powerful way to save time and maintain consistency in your product management process. By following this guide, you can set up automation rules to dynamically assign sequential barcodes to your products—with no manual effort required.
Need to Streamline Your Business Processes?
We specialise in implementing tailored Odoo solutions to optimise workflows.