Enable Dark Mode!
By: Vyshnav AR

How to Create Sequence Numbers in Odoo 16

Technical Odoo 16

Sequence numbers can be generated in a relatively straightforward manner. Each record will have a unique sequence number that may be used to identify it.
In Odoo 16, you can create sequence numbers using the following steps:
? Go to the "Settings" menu and select "Technical" -> "Sequences & Identifiers" -> "Sequences."
? Click the "Create" button to create a new sequence.
? Enter a name for the sequence, such as "Order Number."
? Enter a code for the sequence, such as "order.number."
? Choose a prefix and/or suffix for the sequence, if desired.
? Set the "Next Number" field to the starting number for the sequence.
? Set the "Padding" field to the number of digits you want the sequence number to have.
? Select the "Implementation" option for the sequence, such as "Manual," "Date Range," or "Custom."
? Save the sequence by clicking the "Save" button.
? Use the sequence in your Odoo application by referencing it in your code or by using it in your forms and reports.
Note that Odoo provides several options for customizing sequences, such as defining rules for resetting the sequence number or changing the sequence format. You can explore these options by reviewing the documentation or consulting with an Odoo developer.
To create a sequence number in Odoo 16 through XML, you need to define the sequence in an XML file and then load the file into your Odoo module. Here are the steps:
? Create a new XML file in your Odoo module. For example, you can create a file called “my_module_sequence.xml” in the “data” folder of your module.
? In the XML file, define the sequence using the “ir.sequence” tag. Here’s an example:
<?xml version="1.0" encoding="utf-8"?>
  <data noupdate="1">
    <record id="my_sequence_id" model="ir.sequence">
      <field name="name">My Sequence</field>
      <field name="code">my_sequence_code</field>
      <field name="prefix">MYSEQ</field>
      <field name="padding">5</field>
      <field name="number_next">1</field>
In this example, we define a sequence called “My Sequence” with a code of “my_sequence_code.” The sequence has a prefix of “MYSEQ”, a padding of 5 digits, and starts with a number of 1.
? Save the XML file and include it in your module’s manifest file. In the “data” section of your manifest file, add a line that references the XML file:
'data': [
? Install or upgrade your module to load the sequence into Odoo.
After following these steps, you should be able to use the sequence in your Odoo module by referencing its code, "my_sequence_code." For example, you can use it to generate unique numbers for your records.
def create(self, vals):
    vals['name'] = self.env['ir.sequence'].next_by_code('my_sequence_code')
    return super(MyModel, self).create(vals)
In this example; we use the next_by_code() method of the ir.sequence model to generate a new sequence number for our record. The method takes the sequence code as its parameter.
After following these steps, you should be able to use the sequence in your odoo module by referencing its code, “my_sequence_code”.

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