In this article, I am going to show you how to reset sequence numbers in Odoo14 on a yearly, monthly, and daily basis.
Reset Sequence Number Yearly, Monthly, or at the End of Day in Odoo14
In these examples, we will reset sequence (ir.sequence) numbers based on
- Yearly
- Monthly
- Daily
Why do we need this?
The purpose of re-sequencing the sequence number in Odoo is that we want to re-start the sequence at the end of every year, month, or day. For example, if we want to reset the sequence number yearly then at the start of every new year our sequence will start from 00000001.
Similarly, in the case of month and day, the sequence will automatically start from 00000001.
Read More: How to Create Sequence Number in Odoo
How to Reset Sequence Number in Odoo14
We will generate sequence numbers by Overriding the Save method or with the click of a button. In this example, we will use a button to generate a sequence number. Below is the code snippet to reset the sequence number in Odoo14 based on Year, Month, and Day.
To reset sequence number Odoo14 provides "Sequence Ranges", which would allow us to restart sequence numbering on each day, week, month, or year. If we don't specify the ranges then Odoo will automatically set the reset range for the year only.
How Date Range Works in Sequencing to Restart Numbers in Odoo14
To reset sequence number we will use "<field eval="True" name="use_date_range"/>" in XML.
If we want to reset sequence numbers every year then we have to include the year in the prefix "<field name="prefix">%(y)s-</field>". It means that we want to have a numbering restart for each year.
Create a button to generate sequence
0 Comments