Functions after @frappe.whitelist()

I am unable to execute functions after @frappe.whitelist(). Can someone provide me a solution.

Can you share a code?

class OrderDetails(Document):
	def validate(self):

		# Remove duplicates
		found = {}
		for selected in self.adding:
			if selected.selected in found:
				#frappe.throw(_("Duplicate {0}").format(i))
				self.adding[found[selected.selected]].quantity = self.adding[found[selected.selected]].quantity + self.adding[i].quantity
				print "printgggggggggg"  #can you suggest me where I can see this print result?
				self.adding[i].quantity = 0
				self.adding[i].selected = 'product-04'
			if selected.selected not in found:
				found[selected.selected] = i

def edit_table():
	db = MySQLdb.connect("","root","root","1d2a8e9372" )
	cursor = db.cursor()
	query ="""DELETE FROM `tabAdd to Order` WHERE selected = 'product-04'; """


Frappe provides Database connection no need to create new connect. Use frappe.db.sql(yout_query)

which js method calling edit_table?

Can we only call a js method after @frappe.whitelist()?
If so I am sorry my question is wrong.


Decorator for whitelisting a function and making it accessible via HTTP.
Standard request will be `/api/method/[]`

:param allow_guest: Allow non logged-in user to access this method.

Use as:

def myfunc(param1, param2):

Basically, whitelist method checks permissions, when any request requires to access python method.

So when you make REST call or want to access method from js you need to make those methods as whitelisted.

If you are calling a method from python no need to make it as whitelisted.

1 Like