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()
|
doc.save()
|
||||||
|
|
||||||
@frappe.whitelist()
|
@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
|
from erpnext.crm.doctype.lead.lead import make_lead_from_communication
|
||||||
doc = frappe.get_doc("Communication", communication)
|
doc = frappe.get_doc("Communication", communication)
|
||||||
|
|
||||||
@ -337,6 +337,7 @@ def make_opportunity_from_communication(communication, ignore_communication_link
|
|||||||
|
|
||||||
opportunity = frappe.get_doc({
|
opportunity = frappe.get_doc({
|
||||||
"doctype": "Opportunity",
|
"doctype": "Opportunity",
|
||||||
|
"company": company,
|
||||||
"opportunity_from": opportunity_from,
|
"opportunity_from": opportunity_from,
|
||||||
"party_name": lead
|
"party_name": lead
|
||||||
}).insert(ignore_permissions=True)
|
}).insert(ignore_permissions=True)
|
||||||
|
@ -7,7 +7,7 @@ frappe.ui.form.on("Communication", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setup_custom_buttons: (frm) => {
|
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") {
|
if(frm.doc.reference_doctype !== "Issue") {
|
||||||
frm.add_custom_button(__("Issue"), () => {
|
frm.add_custom_button(__("Issue"), () => {
|
||||||
frappe.confirm(__(confirm_msg, [__("Issue")]), () => {
|
frappe.confirm(__(confirm_msg, [__("Issue")]), () => {
|
||||||
@ -62,17 +62,36 @@ frappe.ui.form.on("Communication", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
make_opportunity_from_communication: (frm) => {
|
make_opportunity_from_communication: (frm) => {
|
||||||
return frappe.call({
|
const fields = [{
|
||||||
method: "erpnext.crm.doctype.opportunity.opportunity.make_opportunity_from_communication",
|
fieldtype: 'Link',
|
||||||
args: {
|
label: __('Select a Company'),
|
||||||
communication: frm.doc.name
|
fieldname: 'company',
|
||||||
},
|
options: 'Company',
|
||||||
freeze: true,
|
reqd: 1,
|
||||||
callback: (r) => {
|
default: frappe.defaults.get_user_default("Company")
|
||||||
if(r.message) {
|
}];
|
||||||
frm.reload_doc()
|
|
||||||
|
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…
x
Reference in New Issue
Block a user