fix: Set address while creating Opportunity from Lead (#18702)

* fix: Set address while creating Opportunity from Lead

* fix: Setting of address in opportunity from Lead
diff --git a/erpnext/crm/doctype/lead/lead.py b/erpnext/crm/doctype/lead/lead.py
index 9292b3a..c9216ee 100644
--- a/erpnext/crm/doctype/lead/lead.py
+++ b/erpnext/crm/doctype/lead/lead.py
@@ -146,15 +146,14 @@
 @frappe.whitelist()
 def make_opportunity(source_name, target_doc=None):
 	def set_missing_values(source, target):
-		address = frappe.db.exists('Dynamic Link', {
-			'link_doctype': target.doctype,
-			'link_name': target.name,
+		address = frappe.get_all('Dynamic Link', {
+			'link_doctype': source.doctype,
+			'link_name': source.name,
 			'parenttype': 'Address',
-			'disabled': 0
-		})
+		}, ['parent'], limit=1)
 
 		if address:
-			target.customer_address = address
+			target.customer_address = address[0].parent
 
 	target_doc = get_mapped_doc("Lead", source_name,
 		{"Lead": {
diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js
index 90a12b7..ec17629 100644
--- a/erpnext/crm/doctype/opportunity/opportunity.js
+++ b/erpnext/crm/doctype/opportunity/opportunity.js
@@ -31,9 +31,9 @@
 
 	party_name: function(frm) {
 		frm.toggle_display("contact_info", frm.doc.party_name);
+		frm.trigger('set_contact_link');
 
 		if (frm.doc.opportunity_from == "Customer") {
-			frm.trigger('set_contact_link');
 			erpnext.utils.get_party_details(frm);
 		} else if (frm.doc.opportunity_from == "Lead") {
 			erpnext.utils.map_current_doc({
@@ -48,13 +48,6 @@
 		frm.get_field("items").grid.set_multiple_add("item_code", "qty");
 	},
 
-	party_name: 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');
 	},