| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
Discuss (mail)
|
| Lines of code | 322 |
| Technical Name |
top_auto_barcode_seqance |
| License | LGPL-3 |
| Website | https://www.topbusiness.io |
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
Discuss (mail)
|
| Lines of code | 322 |
| Technical Name |
top_auto_barcode_seqance |
| License | LGPL-3 |
| Website | https://www.topbusiness.io |

Top Auto Barcode Sequence for Odoo 19
Automatically generate product barcodes and internal references (default_code) by product category, using prefixes, custom patterns, and smart sequence detection within each category.
- Category-based barcode generation
- Automatic internal reference /
default_codegeneration - Custom patterns with zero-padding
- Never overwrites existing product codes
- Works with product variants (standard template ↔ variant fields)
The problem
Managing product barcodes and internal references manually leads to duplicate codes, inconsistent formats, slower product creation, and weak alignment between codes and product categories. Teams need a predictable, category-driven way to assign the next barcode or internal reference without breaking existing data.
The solution
Top Auto Barcode Sequence extends each Product Category with optional barcode prefix, internal reference prefix, barcode pattern, and internal reference pattern. When a product is created or saved with an empty barcode or empty internal reference, the module fills it automatically if the category sequence is enabled. The next value is based on the highest matching code already used on products in the same category— not a global sequence.
What you get
Barcode prefix per category
Define how barcodes should start for each category.
Internal reference prefix per category
Same idea for default_code/ internal reference.
Custom barcode pattern
Format barcodes with placeholders — not a single fixed template.
Custom internal reference pattern
Independent pattern for internal references.
Zero-padded numeric sequences
Use {n:W} for fixed-width numbers (1–32 digits).
Smart next number detection
Next value = max matching code in the same category + 1.
Case-insensitive matching
Finding the “last number” ignores case on the full string.
Existing codes are protected
Non-empty barcodes and internal references are never overwritten.
Variant-compatible behavior
Uses standard product.template writes; barcode and default_code follow Odoo’s variant inverse.
Pattern placeholders
| Placeholder | Meaning |
|---|---|
{p} | Category prefix for that line: either the barcode prefix or the internal reference prefix. |
{n} | Sequence number without padding (e.g. 1, 2, 12). |
{n:W} | Sequence number zero-padded to width W, where W is between 1 and 32. Example:{n:6}→000001. |
Pattern rules
- The pattern must contain exactly one
{n}or{n:W}. - If
{p}is used, the matching prefix field must be filled. - If the pattern is empty but the prefix is set, the default pattern is
{p}-{n}. - Numeric-only sequences are supported (e.g.
{n:8}) with an empty prefix and no{p}in the pattern. - Generated barcodes: prefix from
{p}is normalized to uppercase. - Internal reference: prefix is kept as entered (still limited to letters, digits, and optional hyphen).
Examples
| Prefix | Pattern | Example outputs |
|---|---|---|
AC | Empty (default {p}-{n}) | AC-1, AC-2 |
AC | {p}{n} | AC1, AC2 |
AC | {p}_{n:4} | AC_0001, AC_0002 |
| Empty | {n:8} | 00000001, 00000002 |
How to use it
- Open Product Categories and edit a category.
- Under Automatic barcode/ Automatic internal reference, set the prefix and optionally a custom pattern (see on-form help in Odoo).
- Create or save a product in that category with an empty barcode or empty internal reference. The module fills it when the category sequence is enabled.
Technical notes
- Odoo version: 19.0
- Manifest version: 19.0.1.1.0
- Module folder:
top_auto_barcode_seqance - Depends on:
product - Form inherits:
product.product_category_form_view - Existing non-empty barcodes or internal references are never overwritten.
- Matching when resolving the last number is case-insensitive on the full string.
- On
product.template, barcode anddefault_codeare stored on variants; writes on the template use the standard inverse (same as the Odoo UI).
This module does not add barcode printing, hardware scanning, POS hooks, accounting postings, or special multi-company logic beyond standard product behavior.
Top Business — Odoo implementation and apps ·topbusiness.io
Please log in to comment on this module