fix: Create Opportunity without Default Company from Email (#23097)
* fix: Create Opoortunity without Default Company from Email * fix: Add Prompt to Select Company * Update communication.js Co-authored-by: Nabin Hait <nabinhait@gmail.com>
This commit is contained in:
parent
019d4debb2
commit
c23797e350
@ -325,7 +325,7 @@ def auto_close_opportunity():
|
||||
doc.save()
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_opportunity_from_communication(communication, ignore_communication_links=False):
|
||||
def make_opportunity_from_communication(communication, company, ignore_communication_links=False):
|
||||
from erpnext.crm.doctype.lead.lead import make_lead_from_communication
|
||||
doc = frappe.get_doc("Communication", communication)
|
||||
|
||||
@ -337,6 +337,7 @@ def make_opportunity_from_communication(communication, ignore_communication_link
|
||||
|
||||
opportunity = frappe.get_doc({
|
||||
"doctype": "Opportunity",
|
||||
"company": company,
|
||||
"opportunity_from": opportunity_from,
|
||||
"party_name": lead
|
||||
}).insert(ignore_permissions=True)
|
||||
|
@ -7,7 +7,7 @@ frappe.ui.form.on("Communication", {
|
||||
},
|
||||
|
||||
setup_custom_buttons: (frm) => {
|
||||
let confirm_msg = "Are you sure you want to create {0} from this email";
|
||||
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")]), () => {
|
||||
@ -62,17 +62,36 @@ frappe.ui.form.on("Communication", {
|
||||
},
|
||||
|
||||
make_opportunity_from_communication: (frm) => {
|
||||
return frappe.call({
|
||||
method: "erpnext.crm.doctype.opportunity.opportunity.make_opportunity_from_communication",
|
||||
args: {
|
||||
communication: frm.doc.name
|
||||
},
|
||||
freeze: true,
|
||||
callback: (r) => {
|
||||
if(r.message) {
|
||||
frm.reload_doc()
|
||||
const fields = [{
|
||||
fieldtype: 'Link',
|
||||
label: __('Select a Company'),
|
||||
fieldname: 'company',
|
||||
options: 'Company',
|
||||
reqd: 1,
|
||||
default: frappe.defaults.get_user_default("Company")
|
||||
}];
|
||||
|
||||
frappe.prompt(fields, data => {
|
||||
frappe.call({
|
||||
method: "erpnext.crm.doctype.opportunity.opportunity.make_opportunity_from_communication",
|
||||
args: {
|
||||
communication: frm.doc.name,
|
||||
company: data.company
|
||||
},
|
||||
freeze: true,
|
||||
callback: (r) => {
|
||||
if(r.message) {
|
||||
frm.reload_doc();
|
||||
frappe.show_alert({
|
||||
message: __("Opportunity {0} created",
|
||||
['<a href="#Form/Opportunity/'+r.message+'">' + r.message + '</a>']),
|
||||
indicator: 'green'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
'Create an Opportunity',
|
||||
'Create');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user