feat: implement validation and script creation for Helpdesk CRM settings
This commit is contained in:
parent
8350752f56
commit
8a62ff38af
@ -135,7 +135,7 @@ def get_quotation_url(crm_deal, organization):
|
|||||||
"party_name": crm_deal,
|
"party_name": crm_deal,
|
||||||
"company": erpnext_crm_settings.erpnext_company,
|
"company": erpnext_crm_settings.erpnext_company,
|
||||||
"contact_person": contact,
|
"contact_person": contact,
|
||||||
"customer_address": address
|
"customer_address": address,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
site_url = erpnext_crm_settings.get("erpnext_site_url")
|
site_url = erpnext_crm_settings.get("erpnext_site_url")
|
||||||
@ -147,14 +147,11 @@ def get_quotation_url(crm_deal, organization):
|
|||||||
"party_name": prospect,
|
"party_name": prospect,
|
||||||
"company": erpnext_crm_settings.erpnext_company,
|
"company": erpnext_crm_settings.erpnext_company,
|
||||||
"contact_person": contact,
|
"contact_person": contact,
|
||||||
"customer_address": address
|
"customer_address": address,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Filter out None values and build query string
|
# Filter out None values and build query string
|
||||||
query_string = "&".join(
|
query_string = "&".join(f"{key}={value}" for key, value in params.items() if value is not None)
|
||||||
f"{key}={value}" for key, value in params.items()
|
|
||||||
if value is not None
|
|
||||||
)
|
|
||||||
|
|
||||||
return f"{base_url}?{query_string}"
|
return f"{base_url}?{query_string}"
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,54 @@
|
|||||||
# Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and contributors
|
# Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
# import frappe
|
import frappe
|
||||||
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
|
||||||
class HelpdeskCRMSettings(Document):
|
class HelpdeskCRMSettings(Document):
|
||||||
pass
|
def validate(self):
|
||||||
|
if self.enabled:
|
||||||
|
self.validate_if_helpdesk_installed()
|
||||||
|
self.create_helpdesk_script()
|
||||||
|
|
||||||
|
def validate_if_helpdesk_installed(self):
|
||||||
|
if not self.is_helpdesk_in_different_site:
|
||||||
|
if "helpdesk" not in frappe.get_installed_apps():
|
||||||
|
frappe.throw(_("Helpdesk is not installed in the current site"))
|
||||||
|
|
||||||
|
def create_helpdesk_script(self):
|
||||||
|
if not frappe.db.exists("CRM Form Script", "Helpdesk Integration Script"):
|
||||||
|
script = get_helpdesk_script()
|
||||||
|
frappe.get_doc(
|
||||||
|
{
|
||||||
|
"doctype": "CRM Form Script",
|
||||||
|
"name": "Helpdesk Integration Script",
|
||||||
|
"dt": "CRM Deal",
|
||||||
|
"view": "Form",
|
||||||
|
"script": script,
|
||||||
|
"enabled": 1,
|
||||||
|
"is_standard": 1,
|
||||||
|
}
|
||||||
|
).insert()
|
||||||
|
|
||||||
|
|
||||||
|
def get_helpdesk_script():
|
||||||
|
return """class CRMDeal {
|
||||||
|
onLoad() {
|
||||||
|
this.actions.push(
|
||||||
|
{
|
||||||
|
group: "Helpdesk",
|
||||||
|
hideLabel: true,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
label: "Create customer in Helpdesk",
|
||||||
|
onClick: () => {
|
||||||
|
toast.success("Success Message")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user