Try ERPNext Buy Support Partners Foundation

Insert unique record each row in child table. but below code it just duplicating all the values whenever the Insert button is clicked

var current_user = frappe.session.user;
frappe.ui.form.on(“Milk Entry”,{
verify: function(frm) {
frappe.call({
method: “frappe.client.get”,
args: {
doctype: “User”,
filters: {“email”:current_user} //user is current user here
},
callback: function® {
frappe.model.add_child(cur_frm.doc,“Milk Entry List”,“milk_list”);
$.each(frm.doc.milk_list || [], function(i, v) {
frappe.model.set_value(v.doctype, v.name, “code”,cur_frm.doc.member)
frappe.model.set_value(v.doctype, v.name, “milk_type”,cur_frm.doc.milk_type)
frappe.model.set_value(v.doctype, v.name, “volume”,cur_frm.doc.volume)

			})
			frm.refresh_field('milk_list');
		    cur_frm.set_value("member",r.message["member"]);
	        cur_frm.set_value("milk_type",r.message["milk_type"]);
	        cur_frm.set_value("volume",r.message["volume"]);
		}
	})
}

})