cur_frm.cscript.bitemno=function(doc,cdt,cdn){
var d = locals[cdt][cdn];
frappe.call({
method:"frappe.client.get_value",
args: {
doctype:"Brand Item",
filters: {
name: d.bitemno,
},
fieldname:["lotno","itemsize","weightpie","brandname"]
},
callback: function(r) {
d.lotno =r.message.lotno;
d.itemsize =r.message.itemsize;
d.weightpie =r.message.weightpie;
d.brandname =r.message.brandname;
d.toprice=flt(d.cases)*flt(d.price);
d.topieces=flt(d.cases)*1000;
d.netweig=flt(d.cases)*1000*flt(d.weightpie)/1000;
refresh_field("d.lotno", d.lotno, 'PI_Sale Item');
refresh_field("d.itemsize", d.itemsize, 'PI_Sale Item');
refresh_field("d.weightpie", d.weightpie, 'PI_Sale Item');
refresh_field("d.toprice",d.toprice,"PI_Sale Item");
refresh_field("d.topieces",d.topieces,"PI_Sale Item");
refresh_field("d.netweig",d.netweig,"PI_Sale Item");
refresh_field("d.brandname", d.brandname, 'PI_Sale Item');
}
})
};
cur_frm.cscript.cases=cur_frm.cscript.bitemno;
cur_frm.cscript.price=cur_frm.cscript.bitemno;
cur_frm.cscript.update_totals = function(doc, dt, dn) {
var toc=0; var totp =0; var tofob =0; var towei =0;
$.each(doc.pisaleitem|| [], function(i, d) { toc += d.cases; totp += (flt(d.cases)*1000); towei += (flt(d.cases)*1000*flt(d.weightpie)/1000); tofob += (flt(d.cases)*flt(d.price))});
cur_frm.set_value("tocases", toc);
cur_frm.set_value("pitotpiece", totp);
cur_frm.set_value("tonw", towei);
cur_frm.set_value("tofobpri", tofob);
};
cur_frm.cscript.pisaleitem_add = function(doc) {
cur_frm.cscript.update_totals(doc);
}
cur_frm.cscript.pisaleitem_remove = function(doc) {
cur_frm.cscript.update_totals(doc);
}
cur_frm.cscript.cases = function(doc) {
cur_frm.cscript.update_totals(doc);
};
cur_frm.cscript.price = function(doc) {
cur_frm.cscript.update_totals(doc);
};
I have two fields cases & price in child table. I need to update the related data in child and master at the same time when I update any one of these two. I use two times’ trigger for child and master, but they just execute the late one to update master. They don’t update the data in child. Please do me a favor. Thanks.