Преглед изворни кода

allow for cloning other children

version-14
pratu16x7 пре 8 година
родитељ
комит
e112c71b86
1 измењених фајлова са 10 додато и 1 уклоњено
  1. +10
    -1
      frappe/public/js/legacy/clientscriptAPI.js

+ 10
- 1
frappe/public/js/legacy/clientscriptAPI.js Прегледај датотеку

@@ -248,7 +248,16 @@ _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);
// Deep clone
var d = JSON.parse(JSON.stringify(values));

// Values of unique keys should not be overridden
var unique_keys = ["idx", "name"];
unique_keys.map((key) => {
d[key] && delete d[key];
});

$.extend(doc, d);
}
return doc;
}


Loading…
Откажи
Сачувај