fix: Unable to add details in quotation and opportunity (#19354)

This commit is contained in:
Deepesh Garg 2019-10-21 13:29:44 +05:30 committed by Nabin Hait
parent 4821f38d25
commit 6208755d54
3 changed files with 26 additions and 17 deletions

View File

@ -146,14 +146,7 @@ def _make_customer(source_name, target_doc=None, ignore_permissions=False):
@frappe.whitelist()
def make_opportunity(source_name, target_doc=None):
def set_missing_values(source, target):
address = frappe.get_all('Dynamic Link', {
'link_doctype': source.doctype,
'link_name': source.name,
'parenttype': 'Address',
}, ['parent'], limit=1)
if address:
target.customer_address = address[0].parent
_set_missing_values(source, target)
target_doc = get_mapped_doc("Lead", source_name,
{"Lead": {
@ -173,13 +166,17 @@ def make_opportunity(source_name, target_doc=None):
@frappe.whitelist()
def make_quotation(source_name, target_doc=None):
def set_missing_values(source, target):
_set_missing_values(source, target)
target_doc = get_mapped_doc("Lead", source_name,
{"Lead": {
"doctype": "Quotation",
"field_map": {
"name": "party_name"
}
}}, target_doc)
}}, target_doc, set_missing_values)
target_doc.quotation_to = "Lead"
target_doc.run_method("set_missing_values")
target_doc.run_method("set_other_charges")
@ -187,6 +184,25 @@ def make_quotation(source_name, target_doc=None):
return target_doc
def _set_missing_values(source, target):
address = frappe.get_all('Dynamic Link', {
'link_doctype': source.doctype,
'link_name': source.name,
'parenttype': 'Address',
}, ['parent'], limit=1)
contact = frappe.get_all('Dynamic Link', {
'link_doctype': source.doctype,
'link_name': source.name,
'parenttype': 'Contact',
}, ['parent'], limit=1)
if address:
target.customer_address = address[0].parent
if contact:
target.contact_person = contact[0].parent
@frappe.whitelist()
def get_lead_details(lead, posting_date=None, company=None):
if not lead: return {}

View File

@ -100,10 +100,6 @@ frappe.ui.form.on("Opportunity", {
});
}
}
if (frm.doc.opportunity_from && frm.doc.party_name && !frm.doc.contact_person) {
frm.trigger("party_name");
}
},
set_contact_link: function(frm) {
@ -171,7 +167,7 @@ erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({
if (me.frm.doc.opportunity_from == "Lead") {
me.frm.set_query('party_name', erpnext.queries['lead']);
}
else if (me.frm.doc.opportunity_from == "Cuatomer") {
else if (me.frm.doc.opportunity_from == "Customer") {
me.frm.set_query('party_name', erpnext.queries['customer']);
}
},

View File

@ -23,9 +23,6 @@ frappe.ui.form.on('Quotation', {
refresh: function(frm) {
frm.trigger("set_label");
frm.trigger("set_dynamic_field_label");
if (frm.doc.quotation_to && frm.doc.party_name && !frm.doc.contact_person) {
frm.trigger("party_name");
}
},
quotation_to: function(frm) {