Naming Series according to field without adding suffix

Hi All,

I created a naming series for Item and i set my autoname to naming series. There are 2 options on the naming series either a pattern (CM-.) or according to a field (item_name)

When the user selects CM-. it produces a name of what I want but when the user selects item_name it adds a suffix of 5 numbers.

I can set it to only add a suffix of 1 number but what I want is for it to not add a suffix at all. Is there a way to specify on the naming series to not add a suffix or is this something that can only be done by editing the controllers?

Thank you!

yes use the field you want to set as the naming series.


Thank you for the reply. Unfortunately it still doesn’t fix it and still appends to the item name. The reason for this is because I use Naming By using naming series. The business case is we need a naming series (CM-.) to produce our own part numbers but also we want to be able to add part numbers of an item we buy.

When naming series is enabled the user is forced to select a naming series, and from what it looks like there is no option for a “null” naming series so that it will use the autoname as a fallback.

Is there a way to add an empty option on the naming series selection so it will use the auto-name field?


This is very specific to our company but I will share my solution nonetheless. if you ever need to produce your own item code you can use this as well.

I added a checkbox on a new form. To check if they want to create a custom item code.

Below is the code on the front end that gets triggered when the box is checked:

frappe.ui.form.on('Item', {
custom_cable: function(frm){
    if (frm.doc.custom_cable === 1){{
            method: 'erpnext_core_customizations.erpnext_core_customizations.doctype.item_custom.item_custom.create_custom_name',
            callback: function (r){

And it triggers the server side code below:

def create_custom_name():
    #  Creates a new custom cable number if Custom Cable checked box is checked.
    cm_existing = frappe.db.get_list('Item', filters={
        'item_code': ['like', 'CM-%']
    cm_names = [ for i in cm_existing]
    cm_series = []
    for cm_item in cm_names:
        for item_split in cm_item.split('-'):
            if item_split.isdigit():
    new_name = 'CM-' + (str(max(cm_series)+1))
    return new_name
1 Like