Merge pull request #1352 from anandpdoshi/trigger-link-fields-on-new
[fix] run add fetch and trigger for default values in a new doc
This commit is contained in:
commit
a2aaa30369
3 changed files with 17 additions and 3 deletions
|
|
@ -79,8 +79,6 @@ frappe.ui.form.ScriptManager = Class.extend({
|
|||
}
|
||||
|
||||
function setup_add_fetch(df) {
|
||||
if(df.fieldname==="size")
|
||||
console.log(df.fieldname);
|
||||
if((df.fieldtype==="Read Only" || df.read_only==1)
|
||||
&& df.options && df.options.indexOf(".")!=-1) {
|
||||
var parts = df.options.split(".");
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ $.extend(frappe.model, {
|
|||
}
|
||||
|
||||
frappe.model.add_to_locals(doc);
|
||||
|
||||
return doc;
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ _f.Frm.prototype.refresh = function(docname) {
|
|||
$(document).trigger("form-load", [this]);
|
||||
$(this.page.wrapper).on('hide', function(e) {
|
||||
$(document).trigger("form-unload", [me]);
|
||||
})
|
||||
});
|
||||
} else {
|
||||
this.render_form(is_a_different_doc);
|
||||
if (this.doc.localname) {
|
||||
|
|
@ -538,11 +538,26 @@ _f.Frm.prototype.setnewdoc = function() {
|
|||
|
||||
frappe.route_options = null;
|
||||
}
|
||||
|
||||
me.trigger_link_fields()
|
||||
|
||||
frappe.breadcrumbs.add(me.meta.module, me.doctype)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
_f.Frm.prototype.trigger_link_fields = function() {
|
||||
// trigger link fields which have default values set
|
||||
if (this.is_new()) {
|
||||
$.each(this.fields_dict, function(fieldname, field) {
|
||||
if (field.df.fieldtype=="Link" && this.doc[fieldname]) {
|
||||
// triggers add fetch, sets value in model and runs triggers
|
||||
field.set_value(this.doc[fieldname]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_f.Frm.prototype.runscript = function(scriptname, callingfield, onrefresh) {
|
||||
var me = this;
|
||||
if(this.docname) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue