Skip to content

Commit

Permalink
fix: added reset form script button to reset erpnext form script
Browse files Browse the repository at this point in the history
  • Loading branch information
shariquerik committed Sep 17, 2024
1 parent 2336cc7 commit 01411cd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions crm/fcrm/doctype/erpnext_crm_settings/erpnext_crm_settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt

frappe.ui.form.on("ERPNext CRM Settings", {
refresh(frm) {
if (!frm.doc.enabled) return;
frm.add_custom_button(__("Reset ERPNext Form Script"), () => {
frappe.confirm(
__(
"Are you sure you want to reset 'Create Quotation from CRM Deal' Form Script?"
),
() => frm.trigger("update_form_script")
);
});
},
async update_form_script() {
let script = await frappe.call(
"crm.fcrm.doctype.erpnext_crm_settings.erpnext_crm_settings.get_crm_form_script"
);
if (script.message) {
let form_script = await frappe.db.set_value(
"CRM Form Script",
"Create Quotation from CRM Deal",
"script",
script.message
);
if (form_script.message) {
frappe.msgprint(__("Form Script updated successfully"));
}
}
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def create_customer_in_remote_site(customer, erpnext_crm_settings):
)
frappe.throw(_("Error while creating customer in ERPNext, check error log for more details"))

@frappe.whitelist()
def get_crm_form_script():
return """
async function setupForm({ doc, call, $dialog, updateField, createToast }) {
Expand Down

0 comments on commit 01411cd

Please sign in to comment.