mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-05 13:24:47 +00:00
Merge branch 'responsive' of github.com:webnotes/erpnext into responsive
Conflicts: selling/doctype/lead/lead.txt
This commit is contained in:
@@ -40,9 +40,19 @@ erpnext.LeadController = wn.ui.form.Controller.extend({
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
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.frm.cscript['Create Customer']);
|
||||
@@ -89,63 +99,15 @@ erpnext.LeadController = wn.ui.form.Controller.extend({
|
||||
$.extend(cur_frm.cscript, new erpnext.LeadController({frm: cur_frm}));
|
||||
|
||||
cur_frm.cscript['Create Customer'] = function(){
|
||||
var doc = cur_frm.doc;
|
||||
$c('runserverobj',args={ 'method':'check_status', 'docs':wn.model.compress(make_doclist(doc.doctype, doc.name))},
|
||||
function(r,rt){
|
||||
if(r.message == 'Converted'){
|
||||
msgprint("This lead is already converted to customer");
|
||||
}
|
||||
else{
|
||||
n = wn.model.make_new_doc_and_get_name("Customer");
|
||||
$c('dt_map', args={
|
||||
'docs':wn.model.compress([locals["Customer"][n]]),
|
||||
'from_doctype':'Lead',
|
||||
'to_doctype':'Customer',
|
||||
'from_docname':doc.name,
|
||||
'from_to_list':"[['Lead', 'Customer']]"
|
||||
},
|
||||
function(r,rt) {
|
||||
wn.model.with_doctype("Customer", function() {
|
||||
var customer = wn.model.get_doc("Customer", n);
|
||||
var customer_copy = $.extend({}, customer);
|
||||
|
||||
var updated = wn.model.set_default_values(customer_copy);
|
||||
$.each(updated, function(i, f) {
|
||||
if(!customer[f]) customer[f] = customer_copy[f];
|
||||
});
|
||||
|
||||
loaddoc("Customer", n);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
wn.model.open_mapped_doc({
|
||||
method: "selling.doctype.lead.lead.make_customer",
|
||||
source_name: cur_frm.doc.name
|
||||
})
|
||||
}
|
||||
|
||||
// Create New Opportunity
|
||||
// ===============================================================
|
||||
cur_frm.cscript['Create Opportunity'] = function(){
|
||||
var doc = cur_frm.doc;
|
||||
$c('runserverobj',args={ 'method':'check_status', 'docs':wn.model.compress(make_doclist(doc.doctype, doc.name))},
|
||||
function(r,rt){
|
||||
if(r.message == 'Converted'){
|
||||
msgprint("This lead is now converted to customer. Please create enquiry on behalf of customer");
|
||||
}
|
||||
else{
|
||||
n = wn.model.make_new_doc_and_get_name("Opportunity");
|
||||
$c('dt_map', args={
|
||||
'docs':wn.model.compress([locals["Opportunity"][n]]),
|
||||
'from_doctype':'Lead',
|
||||
'to_doctype':'Opportunity',
|
||||
'from_docname':doc.name,
|
||||
'from_to_list':"[['Lead', 'Opportunity']]"
|
||||
}
|
||||
, function(r,rt) {
|
||||
loaddoc("Opportunity", n);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
wn.model.open_mapped_doc({
|
||||
method: "selling.doctype.lead.lead.make_opportunity",
|
||||
source_name: cur_frm.doc.name
|
||||
})
|
||||
}
|
||||
@@ -95,4 +95,37 @@ class DocType(SellingController):
|
||||
webnotes.conn.sql("""update `tabSupport Ticket` set lead='' where lead=%s""",
|
||||
self.doc.name)
|
||||
|
||||
self.delete_events()
|
||||
self.delete_events()
|
||||
|
||||
@webnotes.whitelist()
|
||||
def make_customer(source_name, target_doclist=None):
|
||||
from webnotes.model.mapper import get_mapped_doclist
|
||||
|
||||
doclist = get_mapped_doclist("Lead", source_name,
|
||||
{"Lead": {
|
||||
"doctype": "Customer",
|
||||
"field_map": {
|
||||
"name": "lead_name",
|
||||
"company_name": "customer_name",
|
||||
"contact_no": "phone_1",
|
||||
"fax": "fax_1"
|
||||
}
|
||||
}}, target_doclist)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
|
||||
@webnotes.whitelist()
|
||||
def make_opportunity(source_name, target_doclist=None):
|
||||
from webnotes.model.mapper import get_mapped_doclist
|
||||
|
||||
doclist = get_mapped_doclist("Lead", source_name,
|
||||
{"Lead": {
|
||||
"doctype": "Opportunity",
|
||||
"field_map": {
|
||||
"campaign_name": "campaign",
|
||||
"doctype": "enquiry_from",
|
||||
"name": "lead",
|
||||
}
|
||||
}}, target_doclist)
|
||||
|
||||
return [d.fields for d in doclist]
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-04-10 11:45:37",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-02 16:03:50",
|
||||
"modified": "2013-07-03 10:24:00",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -40,6 +40,13 @@
|
||||
"doctype": "DocType",
|
||||
"name": "Lead"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "lead_details",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Lead Details",
|
||||
"options": "icon-user"
|
||||
},
|
||||
{
|
||||
"description": "To manage multiple series please go to Setup > Manage Series",
|
||||
"doctype": "DocField",
|
||||
@@ -149,7 +156,9 @@
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "communication_history",
|
||||
"fieldtype": "Section Break"
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Communication History",
|
||||
"options": "icon-comments"
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
@@ -165,7 +174,8 @@
|
||||
"fieldname": "contact_info",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Address & Contact",
|
||||
"oldfieldtype": "Column Break"
|
||||
"oldfieldtype": "Column Break",
|
||||
"options": "icon-map-marker"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.__islocal",
|
||||
@@ -248,7 +258,8 @@
|
||||
"fieldname": "more_info",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "More Info",
|
||||
"oldfieldtype": "Section Break"
|
||||
"oldfieldtype": "Section Break",
|
||||
"options": "icon-file-text"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
test_records = [
|
||||
[{"doctype":"Lead", "lead_name": "_Test Lead", "status":"Open",
|
||||
"email_id":"test_lead@example.com"}],
|
||||
@@ -8,3 +10,17 @@ test_records = [
|
||||
[{"doctype":"Lead", "lead_name": "_Test Lead 3", "status":"Converted",
|
||||
"email_id":"test_lead3@example.com"}],
|
||||
]
|
||||
|
||||
import webnotes
|
||||
import unittest
|
||||
|
||||
class TestLead(unittest.TestCase):
|
||||
def test_make_customer(self):
|
||||
from selling.doctype.lead.lead import make_customer
|
||||
|
||||
customer = make_customer("_T-Lead-00001")
|
||||
self.assertEquals(customer[0]["doctype"], "Customer")
|
||||
self.assertEquals(customer[0]["lead_name"], "_T-Lead-00001")
|
||||
|
||||
webnotes.bean(customer).insert()
|
||||
|
||||
Reference in New Issue
Block a user