feat(api/v2): set name if passed when creating document

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2025-07-03 17:26:55 +05:30
parent ad948c9b98
commit ef5dc763e9
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F

View file

@ -171,7 +171,13 @@ def count(doctype: str) -> int:
def create_doc(doctype: str):
data = frappe.form_dict
data.pop("doctype", None)
return frappe.new_doc(doctype, **data).insert().as_dict()
doc = frappe.new_doc(doctype, **data)
if (name := data.get("name")) and isinstance(name, str | int):
doc.flags.name_set = True
return doc.insert().as_dict()
def copy_doc(doctype: str, name: str, ignore_no_copy: bool = True):