mbauskar | f54b104 | 2017-03-13 16:32:46 +0530 | [diff] [blame] | 1 | frappe.ui.form.on("Communication", { |
| 2 | refresh: function(frm) { |
| 3 | if(frm.doc.reference_doctype !== "Issue") { |
| 4 | frm.add_custom_button(__("Issue"), function() { |
| 5 | frappe.confirm("Are you sure you want to create Issue from this email", function(){ |
| 6 | frm.trigger('make_issue_from_communication'); |
| 7 | }) |
| 8 | }, "Make"); |
| 9 | } |
| 10 | |
Faris Ansari | ab74ca7 | 2017-05-30 12:54:42 +0530 | [diff] [blame] | 11 | if(!in_list(["Lead", "Opportunity"], frm.doc.reference_doctype)) { |
mbauskar | f54b104 | 2017-03-13 16:32:46 +0530 | [diff] [blame] | 12 | frm.add_custom_button(__("Lead"), function() { |
| 13 | frappe.confirm("Are you sure you want to create Lead from this email", function(){ |
| 14 | frm.trigger('make_lead_from_communication'); |
| 15 | }) |
| 16 | }, "Make"); |
| 17 | |
| 18 | frm.add_custom_button(__("Opportunity"), function() { |
| 19 | frappe.confirm("Are you sure you want to create Opportunity from this email", function(){ |
| 20 | frm.trigger('make_opportunity_from_communication'); |
| 21 | }) |
| 22 | }, "Make"); |
| 23 | } |
| 24 | |
| 25 | |
| 26 | frm.page.set_inner_btn_group_as_primary(__("Make")); |
| 27 | }, |
| 28 | |
| 29 | make_lead_from_communication: function(frm) { |
| 30 | return frappe.call({ |
| 31 | method: "frappe.email.inbox.make_lead_from_communication", |
| 32 | args: { |
| 33 | communication: frm.doc.name |
| 34 | }, |
| 35 | freeze: true, |
| 36 | callback: function(r) { |
| 37 | if(r.message) { |
| 38 | frm.reload_doc() |
| 39 | } |
| 40 | } |
| 41 | }) |
| 42 | }, |
| 43 | |
| 44 | make_issue_from_communication: function(frm) { |
| 45 | return frappe.call({ |
| 46 | method: "frappe.email.inbox.make_issue_from_communication", |
| 47 | args: { |
| 48 | communication: frm.doc.name |
| 49 | }, |
| 50 | freeze: true, |
| 51 | callback: function(r) { |
| 52 | if(r.message) { |
| 53 | frm.reload_doc() |
| 54 | } |
| 55 | } |
| 56 | }) |
| 57 | }, |
| 58 | |
| 59 | make_opportunity_from_communication: function(frm) { |
| 60 | return frappe.call({ |
| 61 | method: "frappe.email.inbox.make_opportunity_from_communication", |
| 62 | args: { |
| 63 | communication: frm.doc.name |
| 64 | }, |
| 65 | freeze: true, |
| 66 | callback: function(r) { |
| 67 | if(r.message) { |
| 68 | frm.reload_doc() |
| 69 | } |
| 70 | } |
| 71 | }) |
| 72 | } |
| 73 | }); |