Make_xlsx method not allowed

Is there any way to solve this error when trying to call a function in using a client side scripting on the website?


This is the upper code, obviously there’s more but heres the exact call. I am trying to create a button that can export excel items of a doctype. I can use but it only gives csv.{
method: “frappe.utils.xlsxutils.make_xlsx”,

Are you trying this with an administrator account?

Yes I am. The function is found in the frappe/utils/ Also to add,

Traceback (most recent call last):
  File "apps/frappe/frappe/", line 95, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/", line 47, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/", line 82, in execute_cmd
  File "apps/frappe/frappe/", line 781, in is_whitelisted
    throw(msg, PermissionError, title="Method Not Allowed")
  File "apps/frappe/frappe/", line 534, in throw
  File "apps/frappe/frappe/", line 502, in msgprint
  File "apps/frappe/frappe/", line 451, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.PermissionError: You are not permitted to access this resource.Function frappe.utils.xlsxutils.make_xlsx is not whitelisted.

It’s cause you’re trying to call a non-whitelisted function.

You could try to copy the entire code block (with all the imports) and try to imitate the function via calling to a custom .py file with the copied code block. It might work.

Can this be done without creating a custom app or modifying frappe files?

No, only whitelisted functions can be called via the method.

You could only try to import that function into a .py file, create a whitelisted function that uses that method and call it using the method from a .js file (or client script).

You don’t really need a custom app for this, just create an file (or some other name) in the frappe file directory and you can call into that path. (Custom apps are better cause you can export your modifications during version updates or to new servers.)

If you want a way to use it in the vanilla system with just client & server scripts, then I don’t have an idea on that.

1 Like