Some useful Frappe functions

Here we list some useful Frappe function, which can be used in API and other programming

 · 1 min read

Programming Code Abstract Screen Software Developer Stock Photo 230705539 |  Shutterstock



Get the stock value through API

stock=frappe.db.sql(f"""SELECT actual_qty FROM `tabBin` WHERE item_code='Pen' ORDER BY modified DESC LIMIT 1;""")

frappe.response["message"]=stock


Get the username of the current session

frappe.response["message"]=frappe.session.user


Get fullname of the user of current session

#frappe.response["message"]=frappe.get_fullname()


Get system settings ( Get single doc )

stock=frappe.get_doc('System Settings')


settings = frappe.get_doc('System Settings')

stock = settings.app_name


Get an item from a document ( Permission DONOT apply )


item = frappe.get_doc('Item', 'Pen')

item.item_group



Get an item from a document ( Permission Apply )

stock = frappe.db.get_list('Item')

frappe.response["message"]=stock


Insert data through API

https://oauth.erpgulf.com/api/method/insert-image-test


doc = frappe.new_doc('image-test')

doc.title = frappe.form_dict.title

doc.name1 = frappe.form_dict.name1

doc.insert()

frappe.response['message'] = "Insert completed successfully"

( insert values through form-data )


Get all attachments from a form side bar ( on chrome console )


cur_frm.get_docinfo().attachments




Team ERPGulf

The team behind ERPGulf blogs here, expresses their thoughts, shares the experience, often show the frustrations. Contact us on support@ERPGulf.com

No comments yet

No comments yet. Start a new discussion.

Add Comment