From 16ec981bfd2600dcacf6bb8cb482cf5174b44485 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 25 Sep 2013 20:00:22 +0530 Subject: [PATCH] [cleanup] [minor] fetch lead details in opportunity --- selling/doctype/lead/lead.js | 11 +-- selling/doctype/lead/lead.py | 4 + selling/doctype/opportunity/opportunity.js | 18 +++- selling/doctype/opportunity/opportunity.txt | 100 ++++++++++---------- 4 files changed, 69 insertions(+), 64 deletions(-) diff --git a/selling/doctype/lead/lead.js b/selling/doctype/lead/lead.js index a3ae783867..3c6fda7922 100644 --- a/selling/doctype/lead/lead.js +++ b/selling/doctype/lead/lead.js @@ -33,16 +33,7 @@ erpnext.LeadController = wn.ui.form.Controller.extend({ var doc = this.frm.doc; erpnext.hide_naming_series(); this.frm.clear_custom_buttons(); - - this.frm.dashboard.reset(doc); - if(!doc.__islocal) { - if(doc.status=="Converted") { - this.frm.dashboard.set_headline_alert(wn._("Converted"), "alert-success", "icon-ok-sign"); - } else { - this.frm.dashboard.set_headline_alert(wn._(doc.status), "alert-info", "icon-exclamation-sign"); - } - } - + this.frm.__is_customer = this.frm.__is_customer || this.frm.doc.__is_customer; if(!this.frm.doc.__islocal && !this.frm.__is_customer) { this.frm.add_custom_button("Create Customer", this.create_customer); diff --git a/selling/doctype/lead/lead.py b/selling/doctype/lead/lead.py index da11410f24..316481cbaa 100644 --- a/selling/doctype/lead/lead.py +++ b/selling/doctype/lead/lead.py @@ -126,6 +126,10 @@ def make_opportunity(source_name, target_doclist=None): "campaign_name": "campaign", "doctype": "enquiry_from", "name": "lead", + "lead_name": "contact_display", + "company_name": "customer_name", + "email_id": "contact_email", + "mobile_no": "contact_mobile" } }}, target_doclist) diff --git a/selling/doctype/opportunity/opportunity.js b/selling/doctype/opportunity/opportunity.js index 1ec3f3fc4c..25f28bf3fb 100644 --- a/selling/doctype/opportunity/opportunity.js +++ b/selling/doctype/opportunity/opportunity.js @@ -53,6 +53,11 @@ erpnext.selling.Opportunity = wn.ui.form.Controller.extend({ this.frm.set_query("contact_by", erpnext.queries.profile); } + this.frm.set_query("customer_address", function() { + if(me.frm.doc.lead) return {filters: { lead: me.frm.doc.lead } }; + else if(me.frm.doc.customer) return {filters: { customer: me.frm.doc.customer } }; + }); + this.frm.set_query("item_code", "enquiry_details", function() { return { query: "controllers.queries.item_query", @@ -63,7 +68,6 @@ erpnext.selling.Opportunity = wn.ui.form.Controller.extend({ $.each([["lead", "lead"], ["customer", "customer"], - ["customer_address", "customer_filter"], ["contact_person", "customer_filter"], ["territory", "not_a_group_filter"]], function(i, opts) { me.frm.set_query(opts[0], erpnext.queries[opts[1]]); @@ -151,8 +155,14 @@ cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){ } } -cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) { - if(doc.customer) return get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1); +cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc, dt, dn) { + args = { + address: doc.customer_address, + contact: doc.contact_person + } + if(doc.customer) args.update({customer: doc.customer}); + + return get_server_fields('get_customer_address', JSON.stringify(args),'', doc, dt, dn, 1); } cur_frm.cscript.lead = function(doc, cdt, cdn) { @@ -163,7 +173,7 @@ cur_frm.cscript.lead = function(doc, cdt, cdn) { source_name: cur_frm.doc.lead }) - unhide_field(['customer_name', 'address_display','contact_mobile', + unhide_field(['customer_name', 'address_display','contact_mobile', 'customer_address', 'contact_email', 'territory']); } diff --git a/selling/doctype/opportunity/opportunity.txt b/selling/doctype/opportunity/opportunity.txt index a904f56643..aeedd08bb8 100644 --- a/selling/doctype/opportunity/opportunity.txt +++ b/selling/doctype/opportunity/opportunity.txt @@ -2,7 +2,7 @@ { "creation": "2013-03-07 18:50:30", "docstatus": 0, - "modified": "2013-09-10 10:52:49", + "modified": "2013-09-25 19:32:29", "modified_by": "Administrator", "owner": "Administrator" }, @@ -190,34 +190,16 @@ "options": "icon-bullhorn", "read_only": 0 }, - { - "doctype": "DocField", - "fieldname": "contact_person", - "fieldtype": "Link", - "in_filter": 1, - "label": "Contact Person", - "options": "Contact", - "print_hide": 1, - "read_only": 0 - }, { "doctype": "DocField", "fieldname": "customer_address", "fieldtype": "Link", "in_filter": 1, - "label": "Customer Address", + "label": "Customer / Lead Address", "options": "Address", "print_hide": 1, "read_only": 0 }, - { - "doctype": "DocField", - "fieldname": "customer_name", - "fieldtype": "Data", - "label": "Customer Name", - "print_hide": 0, - "read_only": 1 - }, { "doctype": "DocField", "fieldname": "address_display", @@ -228,12 +210,60 @@ "oldfieldtype": "Small Text", "read_only": 1 }, + { + "description": "To manage Territory, click here", + "doctype": "DocField", + "fieldname": "territory", + "fieldtype": "Link", + "in_filter": 1, + "label": "Territory", + "options": "Territory", + "print_hide": 1, + "read_only": 0, + "reqd": 0, + "search_index": 1 + }, + { + "depends_on": "eval:doc.enquiry_from==\"Customer\"", + "description": "To manage Territory, click here", + "doctype": "DocField", + "fieldname": "customer_group", + "fieldtype": "Link", + "hidden": 0, + "in_filter": 1, + "label": "Customer Group", + "oldfieldname": "customer_group", + "oldfieldtype": "Link", + "options": "Customer Group", + "print_hide": 1, + "read_only": 0, + "reqd": 0, + "search_index": 1 + }, { "doctype": "DocField", "fieldname": "column_break3", "fieldtype": "Column Break", "read_only": 0 }, + { + "doctype": "DocField", + "fieldname": "customer_name", + "fieldtype": "Data", + "label": "Customer Name", + "print_hide": 0, + "read_only": 1 + }, + { + "doctype": "DocField", + "fieldname": "contact_person", + "fieldtype": "Link", + "in_filter": 1, + "label": "Contact Person", + "options": "Contact", + "print_hide": 1, + "read_only": 0 + }, { "doctype": "DocField", "fieldname": "contact_display", @@ -255,36 +285,6 @@ "label": "Contact Mobile No", "read_only": 1 }, - { - "depends_on": "eval:doc.enquiry_from==\"Customer\"", - "description": "To manage Territory, click here", - "doctype": "DocField", - "fieldname": "customer_group", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Customer Group", - "oldfieldname": "customer_group", - "oldfieldtype": "Link", - "options": "Customer Group", - "print_hide": 1, - "read_only": 0, - "reqd": 0, - "search_index": 1 - }, - { - "description": "To manage Territory, click here", - "doctype": "DocField", - "fieldname": "territory", - "fieldtype": "Link", - "in_filter": 1, - "label": "Territory", - "options": "Territory", - "print_hide": 1, - "read_only": 0, - "reqd": 0, - "search_index": 1 - }, { "description": "Filing in Additional Information about the Opportunity will help you analyze your data better.", "doctype": "DocField",