Merge pull request #3570 from pratu16x7/add-child-clone-fix

[fix] Allow for cloning other children
This commit is contained in:
Makarand Bauskar 2017-06-27 16:02:32 +05:30 committed by GitHub
commit 3c58a54a8d

View file

@ -248,7 +248,17 @@ _f.Frm.prototype.clear_table = function(fieldname) {
_f.Frm.prototype.add_child = function(fieldname, values) {
var doc = frappe.model.add_child(this.doc, frappe.meta.get_docfield(this.doctype, fieldname).options, fieldname);
if(values) {
$.extend(doc, values);
// Values of unique keys should not be overridden
var d = {};
var unique_keys = ["idx", "name"];
Object.keys(values).map((key) => {
if(!unique_keys.includes(key)) {
d[key] = values[key];
}
});
$.extend(doc, d);
}
return doc;
}