ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Auto Generate Item Code if not entered by the user


#1

Is there any way the item code can be auto-generated if not entered by the user?


#2

Try using naming series


#3

How do I do that?


#4

This may help with leads and ideas Please give me autoname() Example


#5

Can we do it from “Customize Form” somehow?


#6

I could not say one way or the other. But one can learn much, browsing this forum to learn from other q&a, exploring the code, and of course from trial and error experimentation…


#7

Try below. It might help.
Go to item list, from the drop down menu go to customize form.
In the row series, in the options give your series option. if you hahe more than one give in the next line.
Select update form.

Go to new item.
you should be able to see the naming series.

Below post might help you Item code generation


#8

It just adds a Series in the Item name. It doesn’t auto generate the item code.
I want it to auto generate the item code if not entered by the user.


#9

https://erpnext.com/docs/user/manual/en/customize-erpnext/custom-scripts/generate-item-code-based-on-custom-logic

This might help you solve your problem.


#10

This code creates the code based on Item Group and Brand. But 2 products having same Item Group and Brand get the same code which isn’t unique. And I get this error.

Also, it won’t be creating any new codes except TA, TB, XX, BA, BB and BX.


#11

I understand your concern, however the given link is a generalized custom script for the same query. You have to write some additional codes within the same like add numbers in ascending order or adding 2 digits at the end by random number select between 1-1000.


#12

In the customize form of item, Uncheck the the field, “mandatory”. Check the field “unique” Item code is normally generated based on the naming series automatically if not given by the user. You may try the method once again that I have given. It worked for me.