mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 21:19:19 +00:00
fix: Use make methods to override
This commit is contained in:
@@ -6,6 +6,18 @@ cur_frm.email_field = "email_id";
|
||||
|
||||
erpnext.LeadController = frappe.ui.form.Controller.extend({
|
||||
setup: function () {
|
||||
|
||||
this.frm.make_methods = {
|
||||
'Quotation': () => erpnext.utils.create_new_doc('Quotation', {
|
||||
'quotation_to': this.frm.doc.doctype,
|
||||
'party_name': this.frm.doc.name
|
||||
}),
|
||||
'Opportunity': () => erpnext.utils.create_new_doc('Opportunity', {
|
||||
'opportunity_from': this.frm.doc.doctype,
|
||||
'party_name': this.frm.doc.name
|
||||
})
|
||||
}
|
||||
|
||||
this.frm.fields_dict.customer.get_query = function (doc, cdt, cdn) {
|
||||
return { query: "erpnext.controllers.queries.customer_query" }
|
||||
}
|
||||
@@ -40,32 +52,6 @@ erpnext.LeadController = frappe.ui.form.Controller.extend({
|
||||
|
||||
if (!this.frm.doc.__islocal) {
|
||||
frappe.contacts.render_address_and_contact(cur_frm);
|
||||
|
||||
let make_quotation = this.frm.dashboard.transactions_area.find('.btn-new[data-doctype="Quotation"]').unbind('click');
|
||||
let make_opportunity = this.frm.dashboard.transactions_area.find('.btn-new[data-doctype="Opportunity"]').unbind('click');
|
||||
|
||||
make_quotation.on('click', function() {
|
||||
let doctype = $(this).attr('data-doctype');
|
||||
|
||||
frappe.model.with_doctype(doctype, function() {
|
||||
var new_doc = frappe.model.get_new_doc(doctype);
|
||||
new_doc['quotation_to'] = doc.doctype;
|
||||
new_doc['party_name'] = doc.name;
|
||||
frappe.ui.form.make_quick_entry(doctype, null, null, new_doc);
|
||||
});
|
||||
});
|
||||
|
||||
make_opportunity.on('click', function() {
|
||||
let doctype = $(this).attr('data-doctype');
|
||||
|
||||
frappe.model.with_doctype(doctype, function() {
|
||||
var new_doc = frappe.model.get_new_doc(doctype);
|
||||
new_doc['opportunity_from'] = doc.doctype;
|
||||
new_doc['party_name'] = doc.name;
|
||||
frappe.ui.form.make_quick_entry(doctype, null, null, new_doc);
|
||||
});
|
||||
});
|
||||
|
||||
} else {
|
||||
frappe.contacts.clear_address_and_contact(cur_frm);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user