Try ERPNext Buy Support Partners Foundation

Calling class function in custom report js script?

Hello all,

I have a function my_function(self) in python file, which is a class function. I wanted to call that function using frappe.call()

P.S: This is query report js file.

Here is the solution:
in .js file:

  return frappe.call({
                    method: "module.report.report.py.mydirectfunction",
                    args: {
                        foo: bar
                    },
                    callback: function(r) {
                        //console.log(r);
                        frappe.msgprint("Email sent");
                    }
                });

in .py file:

    @frappe.whitelist()
    def mydirectfunction(foo):
        return ClassReport(foo).my_class_function()