Merge pull request #32327 from akhilnarang/allow-passing-name-in-api
fix(document): don't try to overwrite name if already set
This commit is contained in:
commit
1e30db26dc
3 changed files with 5 additions and 1 deletions
|
|
@ -39,6 +39,8 @@ def handle_rpc_call(method: str):
|
|||
def create_doc(doctype: str):
|
||||
data = get_request_form_data()
|
||||
data.pop("doctype", None)
|
||||
if (name := data.get("name")) and isinstance(name, str):
|
||||
frappe.flags.api_name_set = True
|
||||
return frappe.new_doc(doctype, **data).insert()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ def count(doctype: str) -> int:
|
|||
def create_doc(doctype: str):
|
||||
data = frappe.form_dict
|
||||
data.pop("doctype", None)
|
||||
if (name := data.get("name")) and isinstance(name, str):
|
||||
frappe.flags.api_name_set = True
|
||||
return frappe.new_doc(doctype, **data).insert()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -646,7 +646,7 @@ class Document(BaseDocument, DocRef):
|
|||
def set_new_name(self, force=False, set_name=None, set_child_names=True):
|
||||
"""Calls `frappe.naming.set_new_name` for parent and child docs."""
|
||||
|
||||
if self.flags.name_set and not force:
|
||||
if (frappe.flags.api_name_set or self.flags.name_set) and not force:
|
||||
return
|
||||
|
||||
autoname = self.meta.autoname or ""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue