I have a master table “Proforma Invoice” and child table “PI_Sale Item”. I would like to calculate the totalcase of items in child table. It can trigger the total
field when I add row or update “cases” field. However, it can’t trigger
the total field when I remove(delete) a row. Is there any one could tell me
how to solve this problem. My code is listed below.
frappe.ui.form.on("PI_Sale Item",{
"set_totalcase": function(frm) {
var tocases = 0;
$.each(frm.doc.pisaleitem, function(i, d) {
tocases += d.cases;}
);
frm.set_value("tocases", tocases);
},
"cases": function(frm) {
frm.events.set_totalcase(frm);
},
});
frappe.ui.form.on("Proforma Invoice", "refresh", function(frm) {
frm.events.set_totalcase(frm);
})