fix: validate "format:" expression to only contain one set of {#} pattern

This commit is contained in:
Sumit Bhanushali 2024-12-06 13:03:27 +05:30
parent 62d8d5875a
commit aaefd066f0

View file

@ -1090,6 +1090,12 @@ def validate_series(dt, autoname=None, name=None):
df.unique = 1
break
if autoname and autoname.startswith("format:"):
from frappe.model.naming import BRACED_PARAMS_HASH_PATTERN
if len(BRACED_PARAMS_HASH_PATTERN.findall(autoname)) > 1:
frappe.throw(_("Only one set of {#} pattern is allowed in the format string"))
if (
autoname
and (not autoname.startswith("field:"))