Enable Dark Mode!
By: Ruksana P

How to Create Sequence Numbers in Odoo 17

Technical Odoo 17

In Odoo, sequence numbers play a crucial role in providing unique identifiers for records. These identifiers, often referred to as "sequences" in Odoo, are used to differentiate and identify each record within a particular module or document type. Sequences are customizable and can be configured to follow a specific pattern, such as a prefix, suffix, or a particular numbering scheme. They are commonly employed in various Odoo modules, including sales, purchases, invoices, and other business documents, to ensure the uniqueness and traceability of records throughout the system.

In Odoo 17, you can establish sequence numbers by navigating to the configuration settings, selecting the "Technical" menu, and then accessing the "Sequences" option.

How to Create Sequence Numbers in Odoo 17-cybrosys

From there, you can create and customize sequences according to your specific requirements, enabling the systematic generation of unique identifiers for various records within the system.

Now, we can look into how to customize the sequence number by code. Here we have model named  ‘student.student’ . Create a field to store the sequence information. Then define the model ’student.student’.  In this model field ‘number’ is for sequence number default value is ‘New’.

class Student(models.Model):
   _name = 'student.student'
   number = fields.Char( Reference, default=lambda self: _('New'),
       copy=False, readonly=True, tracking=True)

Include the sequence-related functionality as illustrated in the following code snippet.

def create(self, vals_list):
   """ Create a sequence for the student model """
   for vals in vals_list:
       if vals.get('number', _('New')) == _('New'):
           vals['number'] = self.env['ir.sequence'].next_by_code(
   return super().create(vals_list)

When opting to load a sequence number instead of 'New,' declare the field as shown below, excluding the previously mentioned sequence-related functionality

   number = fields.Char(
       'Reference', readonly=True,tracking=True, copy=false,
       default=lambda self: self.env['ir.sequence'].next_by_code(

Then create an XML file named ‘ my_module_sequence.xml” in the “data” folder of your module.

<?xml version="1.0" encoding="UTF-8" ?>
   <data noupdate="1">
       <record id="ir_sequence_student_student" model="ir.sequence">
           <field name="name">Serial Numbers</field>
           <field name="code">student.reference</field>
           <field name="prefix">STD</field>
           <field name="padding">5</field>
           <field name="number_next">1</field>
           <field name="number_increment">1</field>
           <field name="company_id" eval="False"/>

Id: The ID represents the unique identifier for each record, and that record will be stored 

in the 'ir.sequence' table.

Name: The designation for the record to be generated within the specified model.

Code: The code associated with the sequence for the record.

Prefix: It is a character field providing the sequence prefix for the record.

Suffix:  It is a character field providing the sequence suffix for the record

Padding: It represents the size of the sequence, and we have the flexibility to determine its size.

Number_next: The sequence is incremented by this number.

Number_increment: The number is starting from that number. 

After installation of the module, We can see a new record in ‘ir.sequence’ model is created.

How to Create Sequence Numbers in Odoo 17-cybrosys

Use subsequences per date_rage: It is possible to define a date range for sequences.

Implementation: Standard and No Gap.

For instance, consider a record created for a student sequence with the sequence number STD00001. Subsequently, another record is created, resulting in the sequence number STD00002. If the second record is deleted, and a third record is created, the No Gap implementation method would assign the sequence number STD00001, while the Standard implementation method would assign STD00003. In many scenarios, the Standard implementation is commonly used.

Now, a record can be generated in the 'student.student' model, and the sequence number will be generated automatically.

How to Create Sequence Numbers in Odoo 17-cybrosys

Utilizing this method in Odoo provides the capability to tailor sequence numbers uniquely for each record, enhancing customization options." Refer to our previous blog How to Create Sequence Numbers in Odoo 16, to learn more about sequence number creation in Odoo.

If you need any assistance in odoo, we are online, please chat with us.


Leave a comment




Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635



Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.



Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message