Frappe Whitelist Method Not Working

Hello Every One,

I have call one python function from my js file using frappe.call method, but when I run my code it give me following error,

Traceback (innermost last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 51, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 69, in handle
execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 80, in execute_cmd
method = get_attr(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 101, in get_attr
method = frappe.get_attr(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 737, in get_attr
return getattr(get_module(modulename), methodname)
AttributeError: ‘module’ object has no attribute ‘test’

Below Are My Code For JS & PY Files

JS File:

frappe.call({
type: “GET”,
method: “erpnext.hr.doctype.ai_joining.ai_joining.test”,
callback: function® {
alert(“sucess”)
}
})
}

PY File :

@frappe.whitelist()
def test():
frappe.msgprint(“In PY Function”)
return True

Thanks in advance.

Your code looks fine, can you ensure that the function is definitely in that module?

Try running the test() function directly by doing :

bench execute erpnext.hr.doctype.ai_joining.ai_joining.test

You might have to give a --site option