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.
Yes. Right now that’s the only option.
@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
Instead, you would need a modified implementation, sth. such as
You have three options:
- Provide a PR to core
- overwrite standard “parse_naming_series” within your custom app
- Go with a custom implementation within your autoname method, and don’t call make_autoname.