📐 Sequence
📐


Theory

A sequence is a numerical or alphanumerical identifier generator used to create incremental values for records. Sequences are commonly used to assign identifiers like invoice numbers, sales order numbers, purchase order references, and other document types that require unique IDs.
It is accessible through a technical menu, by following Settings > Technical > Sequences & Identifiers > Sequences

Sequences are customizable based on a specific design.

🏁

Custom sequences is only starting when a new record is created. It is not retroactive !

Let's take sale order as an example to illustrate it:

  • "Name" is the name of the sequence itself
  • "Implementation" gives "No gap" option that ensures no gap that ensures that each previous sequence number has been assigned already and the "Standard" option that doesn't prevent gap if records are deleted. Be aware that the "No gap" option can be slower.
  • "Sequence Code" corresponds to the technical name of the related model
  • "Active" is a boolean to enable or disable the sequence
  • "Prefix" is a fixed start of the sequence
  • "Suffix" is a fixed end of the sequence
  • "Sequence size" is the number of elements in the sequence excluding the prefix and suffix. Odoo will automatically adds some "0" on the left of the "Next number" to get the required size.
  • "Step" is the number by which the "Next number" is incremented.
  • "Next number" corresponds to the next number that will be used by the sequence. 

You can also set up sub-sequences per date range.

Examples

Example 1

By default, payments sequence looks like this : 

Goal = DEP2024/11-001BE with automatic year and month and restarting at 1 every quarter 

Example 2

Instead of customizing an existing sequence, I want to create a new one to use in an automated action for projects name. 

First, I name the sequence to easily find it and thanks to the model technical menu, I retrieve the model technical name. Then, I create the sequence itslef.

If I want to add a dynamic field (for example, the customer name) in the project name, it will be added in the python code of the automation rule. It is different than the sequence.

⚠️ Journal Entries sequencing ⚠️

⚠️ ​  Journal entries sequencing does not use the sequence model.

For customers and vendors bills, sequences adaptation can be done through an action in their list view (only visible if you are in developer mode). 

A pop up arises to specify the first new sequence while choosing to keep current order or reorder it by accounting date. More ever, you can preview modifications with a before and after. 

Based on that, you can either 

  • get rid of the gap in the sequence 

  • customize the sequence