[mapper] added sales order > material request, added postprocess function

This commit is contained in:
Rushabh Mehta
2013-07-04 16:29:03 +05:30
parent 080fcc8fcd
commit 212de6a084
5 changed files with 66 additions and 44 deletions

View File

@@ -105,29 +105,9 @@ cur_frm.cscript['Create Customer'] = function(){
})
}
// 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
})
}

View File

@@ -100,10 +100,7 @@ class DocType(SellingController):
@webnotes.whitelist()
def make_customer(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist
if target_doclist:
target_doclist = json.loads(target_doclist)
doclist = get_mapped_doclist("Lead", source_name,
{"Lead": {
"doctype": "Customer",
@@ -115,4 +112,20 @@ def make_customer(source_name, target_doclist=None):
}
}}, 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]