What Are Sequences?
Sequences generate unique, sequential identifiers for records: SO/2026/0001, INV/2026/0042, WH/OUT/00015. They ensure every document has a unique, predictable reference number.
Default Odoo Sequences
| Document | Default Format | Example |
|---|---|---|
| Sale Order | S + 5-digit | S00042 |
| Invoice | Company prefix + year/number | INV/2026/0001 |
| Purchase Order | P + 5-digit | P00015 |
| Delivery Order | WH/OUT/ + 5-digit | WH/OUT/00023 |
| Manufacturing | MO/ + 5-digit | MO/00008 |
Configuring Sequences
Via UI
- Settings → Technical → Sequences
- Find the sequence (e.g., "Sale Order")
- Edit: prefix, suffix, padding, next number, reset period
Sequence Parameters
# Prefix: text before the number
# Suffix: text after the number
# Padding: minimum digits (5 → 00042)
# Next Number: next value to generate
# Step: increment between numbers (usually 1)
# Dynamic prefix/suffix variables:
# %(year)s → 2026
# %(month)s → 03
# %(day)s → 22
# %(y)s → 26 (2-digit year)
# %(range_year)s → fiscal year
# %(range_month)s → fiscal month
# Examples:
# Prefix: "SO/%(year)s/" Padding: 4 → SO/2026/0001
# Prefix: "INV-" Suffix: "-%(month)s" → INV-0042-03
# Prefix: "PO/%(y)s/" Padding: 5 → PO/26/00001Reset Periods
# Reset the counter at defined intervals:
# - Never: continuous numbering (00001, 00002, ...)
# - Monthly: resets on 1st of each month
# - Yearly: resets on January 1st
# Yearly example:
# SO/2026/0001, SO/2026/0002, ..., SO/2026/0999
# January 1, 2027: SO/2027/0001 (reset!)
# Monthly example:
# INV/2026/03/001, INV/2026/03/002
# April 1: INV/2026/04/001 (reset!)Custom Sequences for Your Model
# Step 1: Define sequence in XML data
<record id="seq_equipment" model="ir.sequence">
<field name="name">Equipment Reference</field>
<field name="code">equipment.item</field>
<field name="prefix">EQ/%(year)s/</field>
<field name="padding">4</field>
<field name="number_next">1</field>
<field name="number_increment">1</field>
<field name="use_date_range">True</field>
</record>
# Step 2: Use in model's create method
class Equipment(models.Model):
_name = 'equipment.item'
reference = fields.Char(
string='Reference',
readonly=True,
default='New',
copy=False,
)
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if vals.get('reference', 'New') == 'New':
vals['reference'] = self.env['ir.sequence'].next_by_code(
'equipment.item'
) or 'New'
return super().create(vals_list)Multi-Company Sequences
# Each company can have its own sequence numbering:
<record id="seq_equipment_company_1" model="ir.sequence">
<field name="name">Equipment - Company 1</field>
<field name="code">equipment.item</field>
<field name="prefix">EQ-US/%(year)s/</field>
<field name="company_id" ref="base.main_company"/>
</record>
<record id="seq_equipment_company_2" model="ir.sequence">
<field name="name">Equipment - Company 2</field>
<field name="code">equipment.item</field>
<field name="prefix">EQ-EU/%(year)s/</field>
<field name="company_id" ref="company_europe"/>
</record>
# next_by_code() automatically picks the sequence for the current companyCommon Issues
| Issue | Cause | Fix |
|---|---|---|
| Gaps in numbers | Normal — cancelled records, rollbacks | By design; not a bug. Regulatory: consult accountant. |
| Numbers out of order | Concurrent creation, different timezones | Expected with multiple workers. Use timestamp if order matters. |
| Number reset didn't happen | use_date_range not enabled | Enable use_date_range on the sequence and create date ranges. |
| Duplicate sequence error | Sequence number_next behind max ID | Update: SET number_next = (SELECT MAX(num) + 1) |
| Wrong year in prefix | Server timezone issue | Set Odoo server timezone to UTC |
Sequence Gaps
Odoo sequences can have gaps. This is by design and normal:
- Cancelled/deleted records leave gaps
- Database rollbacks consume sequence numbers
- Concurrent access may skip numbers
For accounting: some countries require gapless invoice numbering. Use Odoo's built-in journal sequence configuration which handles this (in Enterprise accounting).
DeployMonkey
DeployMonkey's AI agent helps configure sequences for your business — custom prefixes, reset periods, multi-company numbering. Describe your numbering scheme in plain English, and the agent sets it up.