fix: created api to reset crm form script
This commit is contained in:
parent
b9f2730deb
commit
6208ede8ff
@ -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?"
|
"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() {
|
async reset_erpnext_form_script(frm) {
|
||||||
let script = await frappe.call(
|
let script = await frm.call("reset_erpnext_form_script");
|
||||||
"crm.fcrm.doctype.erpnext_crm_settings.erpnext_crm_settings.get_crm_form_script"
|
script.message &&
|
||||||
);
|
frappe.msgprint(__("Form Script updated successfully"));
|
||||||
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"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@ -65,6 +65,18 @@ class ERPNextCRMSettings(Document):
|
|||||||
"is_standard": 1
|
"is_standard": 1
|
||||||
}).insert()
|
}).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):
|
def get_erpnext_site_client(erpnext_crm_settings):
|
||||||
site_url = erpnext_crm_settings.erpnext_site_url
|
site_url = erpnext_crm_settings.erpnext_site_url
|
||||||
api_key = erpnext_crm_settings.api_key
|
api_key = erpnext_crm_settings.api_key
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user