brotherton-erpnext/erpnext/public/js/communication.js

78 lines
1.9 KiB
JavaScript
Raw Normal View History

frappe.ui.form.on("Communication", {
refresh: (frm) => {
// setup custom Make button only if Communication is Email
if(frm.doc.communication_medium == "Email" && frm.doc.sent_or_received == "Received") {
frm.events.setup_custom_buttons(frm);
}
},
setup_custom_buttons: (frm) => {
let confirm_msg = "Are you sure you want to create {0} from this email";
if(frm.doc.reference_doctype !== "Issue") {
frm.add_custom_button(__("Issue"), () => {
frappe.confirm(__(confirm_msg, [__("Issue")]), () => {
frm.trigger('make_issue_from_communication');
})
}, "Make");
}
2017-05-30 07:24:42 +00:00
if(!in_list(["Lead", "Opportunity"], frm.doc.reference_doctype)) {
frm.add_custom_button(__("Lead"), () => {
frappe.confirm(__(confirm_msg, [__("Lead")]), () => {
2018-01-23 10:38:52 +00:00
frm.trigger('make_lead_from_communication');
})
2018-12-23 07:55:58 +00:00
}, __('Create'));
frm.add_custom_button(__("Opportunity"), () => {
frappe.confirm(__(confirm_msg, [__("Opportunity")]), () => {
frm.trigger('make_opportunity_from_communication');
})
2018-12-23 07:55:58 +00:00
}, __('Create'));
}
},
make_lead_from_communication: (frm) => {
return frappe.call({
method: "frappe.email.inbox.make_lead_from_communication",
args: {
communication: frm.doc.name
},
freeze: true,
callback: (r) => {
if(r.message) {
frm.reload_doc()
}
}
})
},
make_issue_from_communication: (frm) => {
return frappe.call({
method: "frappe.email.inbox.make_issue_from_communication",
args: {
communication: frm.doc.name
},
freeze: true,
callback: (r) => {
if(r.message) {
frm.reload_doc()
}
}
})
},
make_opportunity_from_communication: (frm) => {
return frappe.call({
method: "frappe.email.inbox.make_opportunity_from_communication",
args: {
communication: frm.doc.name
},
freeze: true,
callback: (r) => {
if(r.message) {
frm.reload_doc()
}
}
})
}
});