I don’t know what is happening but I cannot call the python method from JS. Here are my codes:
JS
frappe.ui.form.on(‘Agent Statement’, {
refresh: function(frm) {
},
match: function(frm) {
$.each(frm.doc.invoices || [], function(i, d) {
frappe.call({
method: “atndesk.collections.doctype.agent_statement.agent_statement.match_invoice”,
args: {
invoice_no: d.invoice_no
},
callback(r) {
if(r.message) {
msgprint(r.message);
d.requested = 1;
d.request_reference = r.message;
}
}
});
});
}
});
Python
from future import unicode_literals
import frappe
from frappe.model.document import Documentclass AgentStatement(Document):
pass@frappe.whitelist()
def match_invoice(invoice_no):
console.log(“I am here!”)
inv = frappe.db.sql(“”“SELECT parent fromtabOnline Payment Request Invoices
where reference_number = %s”“”, invoice_no, as_dict=1)if inv:
return inv