瀏覽代碼

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…
取消
儲存