Skip to content

Commit

Permalink
fix: created api to reset crm form script
Browse files Browse the repository at this point in the history
  • Loading branch information
shariquerik committed Sep 17, 2024
1 parent b9f2730 commit 6208ede
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
21 changes: 5 additions & 16 deletions crm/fcrm/doctype/erpnext_crm_settings/erpnext_crm_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,13 @@ frappe.ui.form.on("ERPNext CRM Settings", {
__(
"Are you sure you want to reset 'Create Quotation from CRM Deal' Form Script?"
),
() => frm.trigger("update_form_script")
() => frm.trigger("reset_erpnext_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"));
}
}
async reset_erpnext_form_script(frm) {
let script = await frm.call("reset_erpnext_form_script");
script.message &&
frappe.msgprint(__("Form Script updated successfully"));
},
});
12 changes: 12 additions & 0 deletions crm/fcrm/doctype/erpnext_crm_settings/erpnext_crm_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ def create_crm_form_script(self):
"is_standard": 1
}).insert()

@frappe.whitelist()
def reset_erpnext_form_script(self):
try:
if frappe.db.exists("CRM Form Script", "Create Quotation from CRM Deal"):
script = get_crm_form_script()
frappe.db.set_value("CRM Form Script", "Create Quotation from CRM Deal", "script", script)
return True
return False
except Exception:
frappe.log_error(frappe.get_traceback(), "Error while resetting form script")
return False

def get_erpnext_site_client(erpnext_crm_settings):
site_url = erpnext_crm_settings.erpnext_site_url
api_key = erpnext_crm_settings.api_key
Expand Down

0 comments on commit 6208ede

Please sign in to comment.