Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: call option in opportunity #6

Merged
merged 3 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frappe_voxbay/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def cdr_voxbay_log():
call_payload = json.loads(frappe.request.data)
request_log = create_request_log(
call_payload,
request_description="Voxbay Call",
# request_description="Voxbay Call",
service_name="Voxbay",
request_headers=frappe.request.headers,
)
Expand All @@ -59,7 +59,7 @@ def cdr_voxbay_log():
date = call_payload["date"],
status = call_payload["status"],
recording_URL = call_payload["recording_URL"],
type = call_payload["type"],
type = call_payload["call_type"],
)
request_log.status = "Completed"
request_log.save(ignore_permissions=True)
Expand Down
4 changes: 3 additions & 1 deletion frappe_voxbay/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
# page_js = {"page" : "public/js/file.js"}

# include js in doctype views
doctype_js = {"Lead" : "public/js/lead.js"}
doctype_js = {"Lead" : "public/js/lead.js",
"Opportunity": "public/js/opportunity.js",
}
# doctype_list_js = {"doctype" : "public/js/doctype_list.js"}
# doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"}
# doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"}
Expand Down
39 changes: 39 additions & 0 deletions frappe_voxbay/public/js/opportunity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
frappe.ui.form.on("Opportunity", {
refresh: function (frm) {
if (!frm.doc.__islocal) {
frm.add_custom_button(__("Call"), () => {
call_lead(frm);
});
}
}
})

function call_lead(frm) {
let d = new frappe.ui.Dialog({
title: __("Call"),
fields: [
{
label: __("To"),
fieldtype: "Autocomplete",
reqd: 1,
fieldname: "recipient",
default: frm.doc.mobile_no ? frm.doc.mobile_no : "",
ignore_validation: true,
},
],
primary_action_label: __("Call"),
primary_action(values) {
voxbay.utils.clicktocall(values.recipient)
d.hide();
},
});
let numbers = [frm.doc.mobile_no]
if (frm.doc.whatsapp_no) {
numbers.push(frm.doc.whatsapp_no)
}
if (frm.doc.phone) {
numbers.push(frm.doc.phone)
}
d.get_field("recipient").set_data(numbers);
d.show();
}
Loading