From 483818874fad459520b8725986dceae8919ec0ad Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 1 Jul 2024 13:00:01 +0530 Subject: [PATCH] fix: broken UI buttons under `Actions` in Lead --- erpnext/crm/doctype/lead/lead.js | 63 ++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/erpnext/crm/doctype/lead/lead.js b/erpnext/crm/doctype/lead/lead.js index 9eaa60b28e..4cd5e9f007 100644 --- a/erpnext/crm/doctype/lead/lead.js +++ b/erpnext/crm/doctype/lead/lead.js @@ -37,7 +37,13 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller this.frm.add_custom_button(__("Quotation"), this.make_quotation.bind(this), __("Create")); if (!doc.__onload.linked_prospects.length) { this.frm.add_custom_button(__("Prospect"), this.make_prospect.bind(this), __("Create")); - this.frm.add_custom_button(__("Add to Prospect"), this.add_lead_to_prospect, __("Action")); + this.frm.add_custom_button( + __("Add to Prospect"), + () => { + this.add_lead_to_prospect(this.frm); + }, + __("Action") + ); } } @@ -51,33 +57,36 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller this.show_activities(); } - add_lead_to_prospect () { - let me = this; - frappe.prompt([ - { - fieldname: 'prospect', - label: __('Prospect'), - fieldtype: 'Link', - options: 'Prospect', - reqd: 1 - } - ], - function(data) { - frappe.call({ - method: 'erpnext.crm.doctype.lead.lead.add_lead_to_prospect', - args: { - 'lead': me.frm.doc.name, - 'prospect': data.prospect - }, - callback: function(r) { - if (!r.exc) { - me.frm.reload_doc(); - } + add_lead_to_prospect(frm) { + frappe.prompt( + [ + { + fieldname: "prospect", + label: __("Prospect"), + fieldtype: "Link", + options: "Prospect", + reqd: 1, }, - freeze: true, - freeze_message: __('Adding Lead to Prospect...') - }); - }, __('Add Lead to Prospect'), __('Add')); + ], + function (data) { + frappe.call({ + method: "erpnext.crm.doctype.lead.lead.add_lead_to_prospect", + args: { + lead: frm.doc.name, + prospect: data.prospect, + }, + callback: function (r) { + if (!r.exc) { + frm.reload_doc(); + } + }, + freeze: true, + freeze_message: __("Adding Lead to Prospect..."), + }); + }, + __("Add Lead to Prospect"), + __("Add") + ); } make_customer () { -- GitLab