Reset custom series counter

i customize my sale invoice series as:


The series name seems to works, but wheni delete a sales invoice the series not consider the cancellation and the counter is not descreased. If I continue to create and delete sales invoces the counter at every iteration is always counter+1.

This problem happen only if I insert in the series a variable tag like YY, infact if i use the standard series I-, the counter increase or decrease correctly inserting or deleting invoices,

I update the counter directly on table tabSeries to avoid the problem, in this case, but I can’t do update on table every time I have to cancel a draft invoice.

Is there a possibilty to do automatically by the system?


Another strange thing…If I delete the sales invoice the counter increase +1, So, instead of decrease, every activities I do the counter increase…

Isn’t that already possible through Naming Series DocType ?

There’s a section in the DocType labelled ‘Update Series’ in which you can select the series whose counter you want to change. You can use that even for custom naming series.

As for the issue you’re referring to, it seems to be working just fine for me for custom naming series.
I hope you’re deleting it properly in a reverse sequence - If you have 3 invoices and you delete 3rd first then the counter gets decrease by 1, but if you either delete 1st or 2nd invoice first then in that case the counter wont reset.

I have in the table tabSeries a row:

name current
I18- 2

and I have two sales invoice in the table tabSales Invoice

name … naming_series
I18-00001 … I.YY.-
I18-00002 … I.YY.-

If I delete the I18-00002 the counter si not decreased.

The problem is in the naming series saved in the table tabSales Invoice.

If i use I- instead, that is the default Sales Invoice series it works correctly. Modifing manually the field naming_series in the table *tabSales Invoice as I18- it works too, so the problem is in the difference between the name inserted from ERPNEXT in the tabSeries table (I18-) and the value inserted in the tabSales Invoice.

The only way to have a correct behaviour now is to avoid to use the dinamic part .YY. in the naming series, but this si critical for me because I have to reset the counter every year, and if I user only I- this will be not possible because I will have duplicate primary key for the table tabSales Invoice.

Any other solutions?

1 Like

The only solution that I found is to modify the series name from I.YY.- to I18- and modify the naming series every first day of the new year, eliminating the variable part.

1 Like

Apparently, this issue still exists! We need some sort of solution for this…