Need to set naming series with multiple # codes?

Hi there, I have already set a naming series in patient doctype. But I want another naming series with multiple # codes like PRE-{field}-.######.-.####. How can achieve this.
Thanks in advance.

I don’t think this is possible, you can write a custom autoname method to set the name manually.

@ankush
You mean to say I have to set it at server side.

Yes. Right now that’s the only option.

@ankush
What are the parameter of auto_name defination.

@ankush
Can you brief me the code of auto_name a/c to my senherio

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

Your requirement is not possible with the existing standard features.
Normally within a custom autoname method, you would for example do sth. such as:

def autoname(self):
  # will generate sth. as PRE-2022-0001
  year  = dt.datetime.now().year
  self.name = make_autoname("PRE-.{}.-.####".format(year))

When you check the implementation of make_autoname within naming.py, you see the issue within the nested method “parse_naming_series”. It is
image

Instead, you would need a modified implementation, sth. such as
image

You have three options:

  1. Provide a PR to core
  2. overwrite standard “parse_naming_series” within your custom app
  3. Go with a custom implementation within your autoname method, and don’t call make_autoname.