I am trying to move sales invoice items to my payment entry. Have written the following custom script under Doctype Payment Entry. When I try make a payment entry from the sales invoice am getting an error---- Sales Invoice Sales Invoice not found The resource you are looking for is not available— What am I doing wrong please help
frappe.ui.form.on("Payment Entry", {
"onload": function(frm) {
frappe.model.with_doc("Sales Invoice", frm.doc.onload, function() {
var tabletransfer= frappe.model.get_doc("Sales Invoice", frm.doc.onload)
$.each(tabletransfer.items, function(index, row){
d = frm.add_child("items");
d.item_code = row.item_code;
d.item_name = row.item_name;
d.description = row.description;
d.uom = row.uom;
d.stock_qty = row.stock_qty;
d.item_name = row.item_name;
d.rate = row.rate;
d.amount = row.amount;
frm.refresh_field("items");
});
});
}
});