From 28fe73640b629aefe8b3b88d10288610ed36fab6 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Tue, 16 Apr 2019 15:21:51 +0530 Subject: [PATCH] fix: Dynamic link fixes in quotation and opportunity --- erpnext/crm/doctype/opportunity/opportunity.js | 15 +++++++++++++++ erpnext/selling/doctype/quotation/quotation.js | 2 ++ 2 files changed, 17 insertions(+) diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js index 1afea839507..655427ea08b 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.js +++ b/erpnext/crm/doctype/opportunity/opportunity.js @@ -20,6 +20,13 @@ frappe.ui.form.on("Opportunity", { }); }, + customer_lead: function(frm) { + if (frm.doc.opportunity_from == "Customer") { + frm.trigger('set_contact_link'); + erpnext.utils.get_party_details(frm); + } + }, + with_items: function(frm) { frm.trigger('toggle_mandatory'); }, @@ -73,6 +80,14 @@ frappe.ui.form.on("Opportunity", { } }, + set_contact_link: function(frm) { + if(frm.doc.opportunity_from == "Customer" && frm.doc.customer_lead) { + frappe.dynamic_link = {doc: frm.doc, fieldname: 'customer', doctype: 'Customer'} + } else if(frm.doc.opportunity_from == "Lead" && frm.doc.customer_lead) { + frappe.dynamic_link = {doc: frm.doc, fieldname: 'lead', doctype: 'Lead'} + } + }, + set_dynamic_field_label: function(frm){ if (frm.doc.opportunity_from == "Customer") { diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 5455caa069b..257f9919c88 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -44,6 +44,8 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ }, refresh: function(doc, dt, dn) { this._super(doc, dt, dn); + doctype = doc.quotation_to == 'Customer' ? 'Customer':'Lead'; + frappe.dynamic_link = {doc: this.frm.doc, fieldname: doctype.toLowerCase(), doctype: doctype} var me = this;