Item code Generation

Please advise, item code not generate automatically although I set it up as automatic generation.

Hi @dufani1

please set Naming Series in Stock/Stock Settings

works at least in DEV branch

Dear spa
first thanks for your reply.
But I need to set up my items by Item code not by naming series

So you want your items to be named after their item_code instead of the default item_name?

Then go to “Customize Form”, choose “Item” as the DocType and change the value for title_field to “item_code”.

Hi @dufani1,

ok let me make this clear…

1 You want to set up Item with automatic generation in the field item-code

is that right?

Dear codeag
thanks for your support.
I need from Erpnext to generate item code automatically , but this function does not work.
let explain:
when create new item the system should create the item code automatically but it is not created automatically I have to enter it manually. please see the next steps:

1- set naming item code

2- set item code to be createdautomatically

3- item code not created automatically



so please follow these steps…

  1. go to Stock/Stock Settings

and set “Item naming by” to “Naming Series” and hit save

2 go to Setup/Naming Series

and select “Item” for “Select Transaction”

3 configure Naming series Prefix and length of digits by adding hashtags to the prefix e.g. 4 Hashtags for 4 digits to get a total of 9999 item codes to be assigned automatically or leave the hashtags to get 5 digits (default) to get a total 99999 item codes

4 go to item and create new and save

the result is this


thank you very much sap … working

my pleasure,

1 Like


Would it also be possible to set the item code based on the item group selected?

So the item group should be selected first, and based on that selection, the item code should be generated.


1 Like


Does anybody have any idea on how i can create an item that works like a template instead of creating varient parts inside the system - I would like to create a part with Dimensional Attributes and key them into the line as per item, so that when for example i am using a Rebar that is 60’ and i want to cut down - how will the system know that i can use the 60’ to produce a 20’ pcs? and maybe from that 20’ pc a few 4’ers?

Any ideas on how to make that work?


it’s not working for me

I tried this but the field Item code still persists.


Hello Thomas,

did you find a solution to set the item code based on the item group?


You can add a field name to the naming series. So adding on @spa’s example:

In step 3 add a field name led by a dot. (I also think you need to put a dot in front of the following -, but I’m not sure…)
For example ITEM-.item_group.-

When you then enter a new item and select “hardware” as item group the result should be ITEM-hardware-00003.

Would be great if Item code can be generated according to the Item Group Hierarchy. For example, a purchasing item under

Mechanical > Bearings

Could get the item Code ME-BE-####

And also have the possibility to have an alphanumeric numbering series.

It’s a feature request, someone has to program it and submit for inclusion to core.

Well I actually did just that. It’s a bit a workaround, but works like a charm.
I added a custom field to item group and then put that field into the naming series.

So in your szenario you could:

  1. Add a custom field shortcode to item group and
  2. Add a custom field in item item_group_shortcode which fetches from item_group.shortcode
  3. Create naming series like ITEM-.item_group_shortcode.-

You can then set the shortcodes for every item group:
Mechanical: ME
Bearings: ME-BE

Then you get ITEM-ME-BE-00004 as item code.


This is a great idea. Thank you.

Will try that in our next next implementation @avaiskhatri

That’s a great idea! Agreeing with @abidomar, it should be included to core. If you have done this already, could you maybe create a PR?