Can't add child using frappe.model.add_child

Try this:

frappe.ui.form.on("Item", "validate", function(frm) {
    var d = frm.doc;
    frappe.call({
        method:"erpnext.stock.Stock_custom_methods.check_eq_items",
        args: {
            doc: frm.doc
        },
        callback:function(r){
            //if(r.message == "item not in table"){
                var new_row = frm.add_child("engine_compatibility_");
                new_row.name = d.item_code;
                new_row.item_name = d.item_name;
                new_row.item_group = d.item_group;
                new_row.brand = d.brand;
                //}
        }
    });
    refresh_field("engine_compatibility_")
});
2 Likes