Problem with material request api calling

I have added custom js and button(MR) on production order page. When we click on t ‘MR’ button then below ajax will call but I am not getting blank data parameter.
I am checking data parameter in this url : frappe/ at develop · frappe/frappe · GitHub (line 115){
‘url’: ‘api/resource/Material Request’,
‘data’: JSON.stringify({data:{first_name : “John”}}),
‘callback’: function(r) {

You are not setting the correct URL for your frappe call. I’m also not at all clear what you are trying to do with your call? Create a material request maybe?

If so, you don’t need to use python to do that, just javascript. frappe.new_doc('Material Request'); should work I think.

Can you explain more clearly what you are trying to do?


  1. I have added ‘Plan or Revise’ button on on production order page for sending ‘Material Request’.
  2. When we click ‘Plan or receive’ button then ‘MR’ request will send for selected items.

I have written above code for ajax calling for ‘MR’.

I am getting this error when we click on ‘Plan or Revise’ button:
Traceback (most recent call last):
File “/windows/sapconproject/frappe-bench/apps/frappe/frappe/”, line 60, in application
response = frappe.api.handle()
File “/windows/sapconproject/frappe-bench/apps/frappe/frappe/”, line 115, in handle
data = json.loads(
File “/usr/lib/python2.7/json/”, line 339, in loads
return _default_decoder.decode(s)
File “/usr/lib/python2.7/json/”, line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/lib/python2.7/json/”, line 382, in raw_decode
raise ValueError(“No JSON object could be decoded”)
ValueError: No JSON object could be decoded

This is happening because you do not have the correct url.

Have you created a python function that will create these Material Requests? You need something that will take the data (and you need to pass the data for the rows you have checked off) and create material requests for them. You need to either do that with a server side script or write something in Javascript (I’m not 100% sure you can do it in javascript).

Simply calling the REST API function with the method will not do anything in this case.

@Ben_Cornwell_Mott Can you explain below point briefly

Simply calling the REST API function with the method will not do anything in this case.

frappe.ui.form.on(“Production Order”, “plan_or_revise”, function(frm) {{
// doc: frm.doc,
method: “erpnext.manufacturing.doctype.production_planning_tool.production_planning_tool.raise_material_requests”,
doc: frm.doc,
Traceback (most recent call last):
File “/windows/sapconproject/frappe-bench/apps/frappe/frappe/”, line 55, in application
response = frappe.handler.handle()
File “/windows/sapconproject/frappe-bench/apps/frappe/frappe/”, line 21, in handle
data = execute_cmd(cmd)
File “/windows/sapconproject/frappe-bench/apps/frappe/frappe/”, line 52, in execute_cmd
return, **frappe.form_dict)
File “/windows/sapconproject/frappe-bench/apps/frappe/frappe/”, line 907, in call
return fn(*args, **newargs)
File “/windows/sapconproject/frappe-bench/apps/frappe/frappe/”, line 80, in runserverobj
frappe.desk.form.run_method.runserverobj(method, docs=docs, dt=dt, dn=dn, arg=arg, args=args)
File “/windows/sapconproject/frappe-bench/apps/frappe/frappe/desk/form/”, line 33, in runserverobj
fnargs, varargs, varkw, defaults = inspect.getargspec(getattr(doc, method))
AttributeError: ‘ProductionOrder’ object has no attribute ‘erpnext.manufacturing.doctype.production_planning_tool.production_planning_tool.raise_material_requests’

Calling a function which is defined inside a Class of another doctype is not possible via You can only call whitelisted functions (and outside Class) of other doctypes.

Thanks for reply