fix: Set address while creating Opportunity from Lead (#18700)
diff --git a/erpnext/crm/doctype/lead/lead.py b/erpnext/crm/doctype/lead/lead.py
index 4343db0..347f727 100644
--- a/erpnext/crm/doctype/lead/lead.py
+++ b/erpnext/crm/doctype/lead/lead.py
@@ -145,6 +145,17 @@
@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,
+ 'parenttype': 'Address',
+ 'disabled': 0
+ })
+
+ if address:
+ target.customer_address = address
+
target_doc = get_mapped_doc("Lead", source_name,
{"Lead": {
"doctype": "Opportunity",
@@ -157,7 +168,7 @@
"email_id": "contact_email",
"mobile_no": "contact_mobile"
}
- }}, target_doc)
+ }}, target_doc, set_missing_values)
return target_doc