Skip to content

Odoo Sequences: Auto-Numbering Invoices, Orders & Custom Records

DeployMonkey Team · March 22, 2026 12 min read

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

DocumentDefault FormatExample
Sale OrderS + 5-digitS00042
InvoiceCompany prefix + year/numberINV/2026/0001
Purchase OrderP + 5-digitP00015
Delivery OrderWH/OUT/ + 5-digitWH/OUT/00023
ManufacturingMO/ + 5-digitMO/00008

Configuring Sequences

Via UI

  1. Settings → Technical → Sequences
  2. Find the sequence (e.g., "Sale Order")
  3. 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/00001

Reset 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 company

Common Issues

IssueCauseFix
Gaps in numbersNormal — cancelled records, rollbacksBy design; not a bug. Regulatory: consult accountant.
Numbers out of orderConcurrent creation, different timezonesExpected with multiple workers. Use timestamp if order matters.
Number reset didn't happenuse_date_range not enabledEnable use_date_range on the sequence and create date ranges.
Duplicate sequence errorSequence number_next behind max IDUpdate: SET number_next = (SELECT MAX(num) + 1)
Wrong year in prefixServer timezone issueSet 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.