V11.1.13 Fetch Child Table Custom Script not working

Hi team,

As some of you, since updated to v11 [actually v11.1.13 (master)], I can’t make customs scripts to fetch child tables works.

This worked fine on v10:

frappe.ui.form.on("Purchase Order", {
	supplier: function(frm) {
		frm.trigger("banco")
	},
	validate: function(frm) {
		frm.trigger("banco")
	},
	before_submit: function(frm) {
		frm.trigger("banco")
	},
	banco: function(frm) {
		if(frm.doc.docstatus==0 && frm.doc.supplier){
			frappe.model.with_doc("Supplier", frm.doc.supplier, function() {
				var tabletransfer= frappe.model.get_doc("Supplier", frm.doc.supplier)
				$.each(tabletransfer.datos_bancarios, function(index, row){
					d = frm.add_child("datos_bancarios");
					d.bancos = row.bancos;
					d.sucursal = row.sucursal;
					d.cuenta = row.cuenta;
					d.clabe = row.clabe;
				})
			});
		}
	}
});

I also tried with::

frappe.ui.form.on("Purchase Order", {
    supplier: function(frm, cdt, cdn) {
        frm.doc.datos_bancarios = []
        frappe.call({
            method: "frappe.client.get",
            args: {
                name: frm.doc.supplier,
                doctype: "Supplier"
            },
            callback(r) {
                if (r.message) {
                    for (var row in r.message.datos_bancarios) {
                        var child = frm.add_child("datos_bancarios");
                        frappe.model.set_value(child.doctype, child.name, "bancos", r.message.items[row].bancos);
                        frappe.model.set_value(child.doctype, child.name, "clabe", r.message.items[row].clabe);
                    }
                }
            }
        })
    }
});

And updated to Python3 as per suggested:

But both scripts only add a new row empty. Has someone figured how to solve it?

Hi,

I’m Facing the same, did you get any solution for this issue?

1 Like

Anyone with solution to this?

@nabinhait @rmehta any hint highly appreciated, thank you very much.