Hello. I am a beginner in frappe framework. I’m using frappe to develop a custom app.
I tried out auto-incrementing naming series using the format command. The format command uses a field name (item) as well. The problem arised when I was testing my validation code in the python file. I had to do some trials and errors and delete some records which had the same item. As a result, now when I finished testing and the validation code was good, and I need only one record for that item (i.e. (item-code)-001), the auto numbering system takes 008. I think it doesn’t get updated when I delete the previous records.
I want to know how to reset that number to 001 and how to update that data as records may be deleted in the future. I couldn’t find where the program for this is written or where to edit this number. Please help me with this and thanks in advance. The following screenshots should help understand my query better.
Thank you for your reply. I am however using the basic frappe framework and didn’t install erpnext. But I did find a solution for my problem. I came upon this section in the docs: https://frappeframework.com/docs/user/en/basics/doctypes/naming#by-controller-method where I saw that a method called getseries() is being invoked. I understood from reading the source code of this method that tabSeries is the table being updated. I went to mariadb console and found the number for my series and updated it.
I also found a peculiar thing. The name column was empty for that number. I can guess that it’s because I have given a format series with a fieldname whose values change. I wonder that is why it didn’t get updated when I deleted records. Because when I deleted records from other doctypes with simple series like ‘PROCESS-.###’, the number does get updated. I would like to know how to resolve this and make sure the number gets updated when records are deleted in future. Please help in this regard. Thank you.
Hi, do you know where can I update or reset the series # when using the auto name as format? Because I also created an auto name just like what you did. However, I found out that the series does not starts on 0001. I think the Series # are all connected to other generated auto name with series such as how the naming series of the access log.
Now the auto name of my access log and the new doctype does not have a continues number from 00001 and has a skipping number based on who have a new entry from the access log or the new doctype.
Is the control method can be seen at the erpnext? not at the core codes?
Hi @ponyooooo! In the background, the numbers for auto naming are taken from a table called tabSeries. You can view that using
bench --site yoursite.com mariadb command and use the sql language to update the value for your primary key to 0 so that it starts from 1. Actually the issue is when we delete records the number doesn’t reduce. So we have to go update it manually or add some code for it in the core, probably in document.py.
I’m sorry I don’t understand what you say as it has a skipping number. Also, I think each name’s number depends on that value in database. It’s not connected to other names. Look for the method
getseries() in naming.py. You’ll see that they are updating that table I’ve mentioned. If I haven’t addressed your issue properly feel free to say so and let me know what I have to clarify.