[minor] [fix] clear value and run trigger of attach_files: field on removing attachment, if that attachment is being used by a given field

This commit is contained in:
Anand Doshi 2013-07-23 11:48:25 +05:30
parent 2fbe6f9b52
commit 374d44a1ef

View file

@ -182,11 +182,14 @@ wn.ui.form.Attachments = Class.extend({
for(var i=0; i<this.frm.fields.length; i++) {
if(this.frm.fields[i].df.options=="attach_files:") {
var fieldname = this.frm.fields[i].df.fieldname;
refresh_field(fieldname);
if(this.frm.doc[fieldname]!=undefined && !inList(this.frm.fields[i].df.options.split("\n"), this.frm.doc[fieldname])) {
this.frm.cscript.on_remove_attachment && this.frm.cscript.on_remove_attachment(this.frm.doc);
var selected_option = this.frm.fields[i].$input.find("option:selected").val();
if(this.frm.doc[fieldname]!=null && selected_option!==this.frm.doc[fieldname]) {
this.frm.script_manager.trigger(fieldname);
this.frm.set_value(fieldname, "");
}
this.frm.fields[i].refresh();
}
}
}