fix: use sentinel value for checking existence of key in doc while parsing naming series (#20994)

This commit is contained in:
Ritwik Puri 2023-05-15 14:58:14 +05:30 committed by GitHub
parent 80d3f29f6b
commit 2e2c8316c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -304,6 +304,7 @@ def parse_naming_series(
"""
name = ""
_sentinel = object()
if isinstance(parts, str):
parts = parts.split(".")
@ -336,7 +337,7 @@ def parse_naming_series(
part = str(today)
elif e == "FY":
part = frappe.defaults.get_user_default("fiscal_year")
elif doc and (e.startswith("{") or hasattr(doc, e)):
elif doc and (e.startswith("{") or doc.get(e, _sentinel) is not _sentinel):
e = e.replace("{", "").replace("}", "")
part = doc.get(e)
else: