From 43a723c721771144d54f744b8d5e76b12e63f515 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 14 Feb 2025 13:31:32 +0530 Subject: [PATCH] fix: get org address if exist --- .../erpnext_crm_settings/erpnext_crm_settings.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crm/fcrm/doctype/erpnext_crm_settings/erpnext_crm_settings.py b/crm/fcrm/doctype/erpnext_crm_settings/erpnext_crm_settings.py index 1d63807e..a5e5bc3c 100644 --- a/crm/fcrm/doctype/erpnext_crm_settings/erpnext_crm_settings.py +++ b/crm/fcrm/doctype/erpnext_crm_settings/erpnext_crm_settings.py @@ -124,7 +124,8 @@ def get_quotation_url(crm_deal, organization): frappe.throw(_("ERPNext is not integrated with the CRM")) contact = get_contact(crm_deal) - address = get_organization_address(organization).get("name") if organization else None + address = get_organization_address(organization) + address = address.get("name") if address else None if not erpnext_crm_settings.is_erpnext_in_different_site: quotation_url = get_url_to_list("Quotation") @@ -142,7 +143,11 @@ def create_prospect_in_remote_site(crm_deal, erpnext_crm_settings): client = get_erpnext_site_client(erpnext_crm_settings) doc = frappe.get_cached_doc("CRM Deal", crm_deal) contacts = get_contacts(doc) - address = get_organization_address(doc.organization) + address = get_organization_address(doc.organization) or None + + if address and not isinstance(address, dict): + address = address.as_dict() + return client.post_api( "erpnext.crm.frappe_crm_api.create_prospect_against_crm_deal", { @@ -157,7 +162,7 @@ def create_prospect_in_remote_site(crm_deal, erpnext_crm_settings): "annual_revenue": doc.annual_revenue, "contacts": json.dumps(contacts), "erpnext_company": erpnext_crm_settings.erpnext_company, - "address": address.as_dict() if address else None, + "address": address, }, ) except Exception: