From 940e8d24c7e1ded869555cbc326a6927eb68455f Mon Sep 17 00:00:00 2001 From: Pratik Badhe Date: Fri, 8 Aug 2025 08:22:33 +0000 Subject: [PATCH] fix: create quotation --- .../erpnext_crm_settings.py | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 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 7a004387..84351670 100644 --- a/crm/fcrm/doctype/erpnext_crm_settings/erpnext_crm_settings.py +++ b/crm/fcrm/doctype/erpnext_crm_settings/erpnext_crm_settings.py @@ -128,14 +128,35 @@ def get_quotation_url(crm_deal, 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") - return f"{quotation_url}/new?quotation_to=CRM Deal&crm_deal={crm_deal}&party_name={crm_deal}&company={erpnext_crm_settings.erpnext_company}&contact_person={contact}&customer_address={address}" + base_url = f"{get_url_to_list('Quotation')}/new" + params = { + "quotation_to": "CRM Deal", + "crm_deal": crm_deal, + "party_name": crm_deal, + "company": erpnext_crm_settings.erpnext_company, + "contact_person": contact, + "customer_address": address + } else: site_url = erpnext_crm_settings.get("erpnext_site_url") - quotation_url = f"{site_url}/app/quotation" - + base_url = f"{site_url}/app/quotation/new" prospect = create_prospect_in_remote_site(crm_deal, erpnext_crm_settings) - return f"{quotation_url}/new?quotation_to=Prospect&crm_deal={crm_deal}&party_name={prospect}&company={erpnext_crm_settings.erpnext_company}&contact_person={contact}&customer_address={address}" + params = { + "quotation_to": "Prospect", + "crm_deal": crm_deal, + "party_name": prospect, + "company": erpnext_crm_settings.erpnext_company, + "contact_person": contact, + "customer_address": address + } + + # Filter out None values and build query string + query_string = "&".join( + f"{key}={value}" for key, value in params.items() + if value is not None + ) + + return f"{base_url}?{query_string}" def create_prospect_in_remote_site(crm_deal, erpnext_crm_settings):