feat(api/v2): set name if passed when creating document
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
parent
ad948c9b98
commit
ef5dc763e9
1 changed files with 7 additions and 1 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue