Customizing naming series

Hello, I’m trying custom my naming series to code of item.
It’s like, if the item code is 4545 then, the serie will be 4545-0001.
How can i do that?

write method for autoname = make_autoname(self.item_code + '-.#####')

Show me the complete code please.
I tried:

frappe.ui.form.on(“Item”, {
refresh: function(frm) {
// use the __islocal value of doc, to check if the doc is saved or not
self.item_code = make_autoname(self.item_code + ‘-.#####’);

And not works at all…

you should do it in server side in not in client side

1 Like

As @Mohammed_Redha said you have to write it in python file (server side).
you can use for it.

In give an autoname function path for Item.

"Item": {
	   "autoname": ""

Where your method will be like, (In Python file)

def item_autoname(doc, method):
	from frappe.model.naming import make_autoname = make_autoname(doc.item_code + '-.#####')

Hope it resolve your problem.


I have to create an app to script server side?

yes, If you want to not lose your changes after update

1 Like

I’ll try do that, thank’s for help!

I worked on this too, here was how I did it:


This is JS, what file i code this? python file can be found at the root of every app.
You can customize erpnext using this file.

This should help you :

Also @kolate_sambhaji did a very nice explanation about exploiting the autoname function to add some context.

1 Like


Did you get this working? Great to skype with you on Friday, it seemed like you were really close. If you did get what you were looking for, post your solution for the community; there’s an excellent chance somebody else wants to do the same thing.

Not yet, i tried with this post what you share:
Resulting in “PO-1603-WN-00001”
(where “Vendor ID” is custom field created under Document: Supplier and
fetched into Purchase Order.)

but {} it’s not permited.
So, i don’t know if i have to create an app to do that on server side, or if i can do that with a custom script… each person tell me each person tells me something different

Actually, it should be PO-.YY.MM.-.vendor_id.-.#####. Ignore the {} braces, just seperate the fields with dots (.). This is the real way.


Tried the above ?

not works at all…

The solution is @Sangram s post #5.
It was talked over gitter and fixed.
Custom app was not installed in his site.