diff --git a/erpnext/crm/doctype/lead/lead.js b/erpnext/crm/doctype/lead/lead.js index 8df7dab6f7d..de87100eb51 100644 --- a/erpnext/crm/doctype/lead/lead.js +++ b/erpnext/crm/doctype/lead/lead.js @@ -40,6 +40,32 @@ erpnext.LeadController = frappe.ui.form.Controller.extend({ if (!this.frm.doc.__islocal) { frappe.contacts.render_address_and_contact(cur_frm); + + let make_quotation = this.frm.dashboard.transactions_area.find('.btn-new[data-doctype="Quotation"]').unbind('click'); + let make_opportunity = this.frm.dashboard.transactions_area.find('.btn-new[data-doctype="Opportunity"]').unbind('click'); + + make_quotation.on('click', function() { + let doctype = $(this).attr('data-doctype'); + + frappe.model.with_doctype(doctype, function() { + var new_doc = frappe.model.get_new_doc(doctype); + new_doc['quotation_to'] = doc.doctype; + new_doc['party_name'] = doc.name; + frappe.ui.form.make_quick_entry(doctype, null, null, new_doc); + }); + }); + + make_opportunity.on('click', function() { + let doctype = $(this).attr('data-doctype'); + + frappe.model.with_doctype(doctype, function() { + var new_doc = frappe.model.get_new_doc(doctype); + new_doc['opportunity_from'] = doc.doctype; + new_doc['party_name'] = doc.name; + frappe.ui.form.make_quick_entry(doctype, null, null, new_doc); + }); + }); + } else { frappe.contacts.clear_address_and_contact(cur_frm); } diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index 8d590a0c9d0..61a4fd487e5 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -113,6 +113,31 @@ frappe.ui.form.on("Customer", { // indicator erpnext.utils.set_party_dashboard_indicators(frm); + let make_quotation = frm.dashboard.transactions_area.find('.btn-new[data-doctype="Quotation"]').unbind('click'); + let make_opportunity = frm.dashboard.transactions_area.find('.btn-new[data-doctype="Opportunity"]').unbind('click'); + + make_quotation.on('click', function() { + let doctype = $(this).attr('data-doctype'); + + frappe.model.with_doctype(doctype, function() { + var new_doc = frappe.model.get_new_doc(doctype); + new_doc['quotation_to'] = frm.doc.doctype; + new_doc['party_name'] = frm.doc.name; + frappe.ui.form.make_quick_entry(doctype, null, null, new_doc); + }); + }); + + make_opportunity.on('click', function() { + let doctype = $(this).attr('data-doctype'); + + frappe.model.with_doctype(doctype, function() { + var new_doc = frappe.model.get_new_doc(doctype); + new_doc['opportunity_from'] = frm.doc.doctype; + new_doc['party_name'] = frm.doc.name; + frappe.ui.form.make_quick_entry(doctype, null, null, new_doc); + }); + }); + } else { frappe.contacts.clear_address_and_contact(frm); }