Hello for my ecommerce integration i need to rename Item Group so My Slugs Matchs Erp Item Group name, so far bad luck
i’m using
put http://mysite.localhost:8000/api/resource/Item Group/{some name}
body {
“item_group_name”: “something”,
}
but the problem is Item Group Item_group_name does change but the main name (unique one) doesn’t
any solutions ?
To modify the 'name'
key on any Document, you can call the Python function frappe.rename_doc()
. This function does 2 important things:
Updates the value on your Document.
Searches for references (Links) to your Document, and updates the reference values too.
However, I do not believe there is a standard API for rename.
See response below from Youssef for how to call via REST API.
Hi
Use this API
:param doc: JSON or dict object with the properties of the document to be updated'''
if isinstance(doc, str):
doc = json.loads(doc)
doc = frappe.get_doc(doc)
doc.save()
return doc.as_dict()
@frappe.whitelist(methods=['POST', 'PUT'])
def rename_doc(doctype, old_name, new_name, merge=False):
'''Rename document
:param doctype: DocType of the document to be renamed
:param old_name: Current `name` of the document to be renamed
:param new_name: New `name` to be set'''
new_name = frappe.rename_doc(doctype, old_name, new_name, merge=merge)
return new_name
@frappe.whitelist(methods=['POST', 'PUT'])
def submit(doc):
2 Likes