Search Here

How to Create sequence number in Odoo

 Adding sequence number for records in Odoo is not a rocket science. In this article you will learn what is sequence number and how to generate unique sequence number in Odoo.

Generate Sequence Numbesr in Odoo | What is Sequence Number in Odoo


After reading this article you know:

  • What is sequence number in odoo
  • How to create sequence number in odoo


What is sequence number in Odoo

Sequence number in odoo is an auto incremented field, that generate a unique number for every record when a new record is created. For example in sales order or invoices each records are distinguish by their sequence number.

Read More: Reset Sequence Number Yearly, Monthly or at the End of Day in Odoo

How to generate sequence number in odoo

To generate auto incremented field (sequence number) in odoo we will use odoo ir.sequence built in model, follow below steps:

  1. Create record for sequence number in XML file by using ir.sequence model
  2. Create a new field in your model, you can give any name like sequence or application_no etc
  3. Override Odoo create method, and in that method use ir.sequence model with our created record (in step no 1) to generate sequence number. You can also generate sequence number on button click event.

create_sequence_number_in_odoo.xml



Name Description
id Unique XML ID to reference this record
name Name (Any Name) of the record created in the "ir.sequence" model
code Sequence code
active A boolean field to indicate whether this record is active or not
prefix We can give any prefix to that sequence record, if we set OR as prefix than the sequence displays like OR00001
padding To determine size of sequence we use padding, for example if we set padding 5, than sequence would be OR00001
number_next Next number that will be used in sequence
number_increment Determine the next number of the sequence will be incremented by this

create_sequence_number_in_odoo.py



Recommend: 

Post a Comment

2 Comments

  1. but is shows error when we create a record from an other model,
    The error is following


    The operation cannot be completed:
    - Create/update: a mandatory field is not set.
    - Delete: another model requires the record being deleted. If possible, archive it instead.

    Model: sale dealer commission line (sale.dealer.commission.line), Field: Name (name)

    ReplyDelete
    Replies
    1. you are not creating or updating some of the required field. that's why you are facing above issue

      Delete