In Odoo 16, the sequence number is a field used to assign a unique, incremental number to records in a specific model. It helps in maintaining the order or sequence of records and can be useful in various scenarios.
2. In Odoo 16, the sequence number is a field used to assign a
unique, incremental number to records in a specific model. It
helps in maintaining the order or sequence of records and can be
useful in various scenarios.
3. Here are some common use cases of sequence number:
• Order and Ranking: Sequence numbers can be used to establish a specific order or ranking for records within a model. For
example, in a list of tasks, the sequence number can determine the priority or order in which the tasks should be executed.
• Document Numbering: Sequence numbers are commonly used to generate unique document numbers, such as invoices,
purchase orders, sales orders, etc. Each time a new record is created, the sequence number field is automatically assigned a
new, sequential value.
• Sorting and Filtering: The sequence number field can be used for sorting and filtering records. By sorting records based on the
sequence number, you can view them in a specific order, such as ascending or descending.
• Workflow and Automation: Sequence numbers can be leveraged in workflow and automation rules. For example, you can
define specific actions or triggers based on the sequence number of a record, allowing you to automate certain processes or
notifications.
• Reference and Identification: Sequence numbers can serve as a reference or identification for records. They provide a unique
identifier that can be used to easily locate or reference specific records within a model.
4. Let's talk about how to create a sequence number in Odoo 16 using Python and XML.
• As seen in the image below, first we need to define a field for the sequence.
• Then we need to define a function for creating sequence in the particular model.
5. • And after that, make an XML file and create record for that.
6. Let’s discuss each item in the XML file.
• The ID is the ID of that record, it is unique for each record. And that record will be stored in the ir.sequence table.
• name - is the Name of the record that will be created on the specified model.
• Code - is the sequence code for the record.
• Prefix - is a character field that gives the prefix of the sequence for the record.
• Padding - is the size of the sequence. We can decide the size.
• Active- It determines whether the sequence is currently active or not.
• Number Next - The number_next field determines the value of the next sequence number to be generated.
• Number Increment - The number_increment field determines the amount by which the sequence number increases with each new
number generated.
8. In the above screenshot we can see a sequence number is generated with a prefix of IN and the
number is 0001 the first number is automatically generated as 1 and we create another record
in the same model that will be 2 and so on and also here we can see the padding of the number
is 4 that we will mentioned in the code.
9. Also we can configure the sequence number from the general setting of Odoo,
• 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 "Your Model."
• Enter a code for the sequence, such as "your.model."
• 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.
10. Check our company website
for related blogs and Odoo book.
https://www.youtube.com/watch?v=lXD4
fI3tBdw