From f8946b1e31c59038fb059d8c3f78d8b600844a71 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 18 Jun 2012 18:04:28 +0530 Subject: [PATCH] fix in buttons displayed - on change of status in lead form --- erpnext/selling/doctype/lead/lead.js | 21 +++++++++++++++------ public/js/all-app.js | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/erpnext/selling/doctype/lead/lead.js b/erpnext/selling/doctype/lead/lead.js index 5d434495c0..389dce0db1 100644 --- a/erpnext/selling/doctype/lead/lead.js +++ b/erpnext/selling/doctype/lead/lead.js @@ -45,15 +45,24 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { cur_frm.cscript.make_communication_body(); } +cur_frm.cscript.refresh_custom_buttons = function() { + cur_frm.clear_custom_buttons(); + if(!doc.__islocal && !in_list(['Converted', 'Lead Lost'], doc.status)) { + if (doc.source != 'Existing Customer') { + cur_frm.add_custom_button('Create Customer', + cur_frm.cscript['Create Customer']); + } + cur_frm.add_custom_button('Create Opportunity', + cur_frm.cscript['Create Opportunity']); + cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms); + } +} + cur_frm.cscript.refresh = function(doc, cdt, cdn) { // custom buttons //--------------- - cur_frm.clear_custom_buttons() - if(!doc.__islocal && !in_list(['Converted', 'Lead Lost'], doc.status)) { - if (doc.source != 'Existing Customer') cur_frm.add_custom_button('Create Customer', cur_frm.cscript['Create Customer']); - cur_frm.add_custom_button('Create Opportunity', cur_frm.cscript['Create Opportunity']); - cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms); - } + cur_frm.cscript.refresh_custom_buttons(); + erpnext.hide_naming_series(); if (!doc.__islocal) cur_frm.cscript.render_communication_list(doc, cdt, cdn); diff --git a/public/js/all-app.js b/public/js/all-app.js index 298840eb97..ec43c7013d 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -1748,7 +1748,7 @@ continue;var fn=f.fieldname?f.fieldname:f.label;var fld=make_field(f,this.doctyp if(f.fieldtype=='Section Break'){sec=fld;this.sections.push(fld);} if((f.fieldtype=='Section Break')&&(fl[i+1])&&(fl[i+1].fieldtype!='Column Break')&&!f.hidden){var c=this.layout.addcell();$y(c.wrapper,{padding:'8px'});}}} _f.Frm.prototype.add_custom_button=function(label,fn,icon){this.frm_head.appframe.add_button(label,fn,icon);} -_f.Frm.prototype.clear_custom_buttons=function(){} +_f.Frm.prototype.clear_custom_buttons=function(){this.frm_head.refresh_toolbar()} _f.Frm.prototype.add_fetch=function(link_field,src_field,tar_field){if(!this.fetch_dict[link_field]){this.fetch_dict[link_field]={'columns':[],'fields':[]}} this.fetch_dict[link_field].columns.push(src_field);this.fetch_dict[link_field].fields.push(tar_field);} _f.Frm.prototype.setup_client_script=function(){if(this.meta.client_script_core||this.meta.client_script||this.meta.__js){this.runclientscript('setup',this.doctype,this.docname);}}