Error in Function Argument

Hi Everyone,

I am trying to create a function but I am receiving error related to arguments passed to it.

I appreciate, if anyone can let me know what I did wrong in this:

Python Code:

def uom_conversion_factor(item_code, uoms):
    i=frappe.db.sql("""select distinct conversion_factor from `tabUOM Conversion Detail` where parent=%s and uom!=%s limit 1""", (item_code,uoms))
    if i[0][0]!=0:
	return i[0][0]
	return 0

Javascript Code:

frappe.ui.form.on("Supplier Quotation Item","purchase_uom", function(frm, cdt, cdn) { 
var d =locals[cdt][cdn]
var item=frappe.get_doc(cdt,cdn);
var data =  {
	    "item_code": d.item_code,
            "uoms": d.purchase_uom
                       method: "library_management.conversion_details.uom_conversion_factor",
	                args: data, 
                       callback: function(r) 
                        frappe.model.set_value(cdt, cdn, "conversion_factor", r.message);

Hi @ruchin78

add the parent and uom value in quotes like where parent='%s' and uom!='%s' may be this is causing error.

Can you share the error traceback ?

Thanks, Makarand


I did that but it is still showing the same error.
Apart from that, I just want to say that my earlier functions are not using any quote for the same and are working fine.

Ruchin Sharma

@ruchin78 can you share the traceback ?


Here is the traceback, however I did change the name of the function by thinking that it may resolve the problem.

Traceback (innermost last):
File “/home/vishnu/frappe-bench/apps/frappe/frappe/”, line 57, in application
response = frappe.handler.handle()
File “/home/vishnu/frappe-bench/apps/frappe/frappe/”, line 19, in handle
File “/home/vishnu/frappe-bench/apps/frappe/frappe/”, line 36, in execute_cmd
ret =, **frappe.form_dict)
File “/home/vishnu/frappe-bench/apps/frappe/frappe/”, line 806, in call
return fn(*args, **newargs)
TypeError: check_uom() takes exactly 2 arguments (1 given)

@ruchin78 If check_uom is defined is class the first parameter must be ‘self’ like

def check_uom(self,uom):

It is resolved now, actually the problem was conflicting of 2 arrays therefore it was passing an undefined to the function.

However, my code was perfect.

Ruchin Sharma