Sequences Next Number Cron job

Hello community.


My idea to reset this number on daily bases, maybe by using tryton cron jobs or using pgsql cron jobs.

What do you think is the best? and is there any reference for the usage of tryton cron jobs?

I do not think it is possible to guarantee that the cron job will reset the sequence exactly at the right time, so you may have a number generated with the old next number.
But why resetting the sequence?
Otherwise, you could use something else than a sequence like counting the number of record for the date and increase by one (but requires to lock the table to avoid concurrency).

I have done it using Postgresql cron job, that is reseting the sequence next number everyday.
And to avoid concurrency I added the year month day then the sequence number which is resting at the end of each day.

For me, a cron job can not guarantee that the sequence will be reset at the right time prior to any usage for the day. Maybe for your case, it is not a problem, but then why resetting the sequence?

For sure it depends on the use case, in my case there will be no demand on the targeted sequence, this is the only solution that I can do so far, the idea is very similar to queue number issuing, every day the queue must begin from number 1.

But your solution does not guarantee that. You can not enforce that the cron will be run at the right time.
If you really want to make a queue numbering, you must go with the solution:

Any reference to this code will help me a lot as similar requirement came up to me where I need to make my field editable from particular date xx/yy/2021 to xx/yy/2021 and cron job continuously run checking this condition every time filling the record.