Naming Series in Code

Hello there,

when creating a Sales Order via code, I can not figure out, how to let the system know to use the naming_series in the title. All Sales Orders have only SO- as title.

item = frappe.get_doc({
	"doctype": "Sales Order",
	"naming_series": "SO-",
	"transaction_date": date_purchased,
	"delivery_date": delivery_date,
	"currency": data['currency_code'],
	"price_list": "Standard-Shop",
	"price_list_currency": data['currency_code'],
	"fiscal_year": fiscal_year,
	"source": "Shop",
	#"order_type": "Shop",
	"order_type": "Sales",
	#"status": "Draft",
	"ignore_pricing_rule": 1,
	"apply_discount_on": "Net Total",
	"items": get_items_list(data['items']),
	"taxes": get_taxes_list(data['items'], data['totals'])

@ci2016, can you elaborate your question?

@max_morais_dmm Of course. The example obove creates one or multiple (in a loop) Sales Order(s) with the title “SO-”.

Of course i want it to be full naming series (which is saved in the naming_series column), not only “SO-”, but I don’t now how to get the “next” naming_series or tell the insert() method to generate it.

@ci2016, you dont need do anything! the ERP, will get the ‘SO-’ and complete with the leading zeros and generate the next number while insert!

Dont forget that it need be enabled in Selling Settings, naming by Naming Series

I have this as result:

May be you have customized the “Naming Series” options and “SO-” is not there. Thats why while you are passing “SO-”, it is taking as a valid one and assigning default naming series.

I removed "naming_series": "SO-XTC-", from my code above. I have still the same issue. I think there must be a detail I am missing.

Check what Naming Series is set under
System -> Data -> Naming Series
It should be like:

If it is not, then you need to update the Naming Series by setting the same series and then click update button, below it.

Ruchin Sharma

I see this


Step 1: Just click on update button.
Step 2: Goto Sales Order and reload the form.
Step 3: Try to generate a new sales order number and see if the generated number is like SO-0001 etc.

Ruchin Sharma

Thank you ruchin78

As you can see in my screenshot above the naming_series works correctly in the column “ID”. Th Problem is the Column “Bezeichnung”, which is the title column does not show the value, which is in the column “ID”.

Hi @ci2016,

I appreciate, if you can share the properties and code associated with the column “Bezeichnung”.

Ruchin Sharma

Hi @ruchin78,

it’s a default column of ERPNext. I have not created it.

I think I should ask my question clearlier. The naming series is (!) working, as we can see in the default column ID.

Please have a look at this:

As you can see on the right side, I have a naming series, which I want to have. My only issue is that I am not able to use that column as my title column. I tried everything from customize form to changing the doctypes. I also installed a fresh instance of ERPNext and tried to figure that out.

I didn’t find any documentation about using the naming series as title. I also want this to work for customers as “CUST-0001”, “CUST-0002”, or Items “ITEM-0001”, “ITEM-0002” and so on. In a fresh bitnami stack of ERPNext there were Items named ITEM-0001, ITEM-0002 and ITEM-0003, but creating the next item, it was named by the Item Name. This seems very strange to me and I am stuck with this issue.

Remove the Title Field property from “Customize Form”, or set it as name

1 Like

Thank you rmehta. I made it work as by your advice.