mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-09 08:02:51 +00:00
[mapper] added sales order > material request, added postprocess function
This commit is contained in:
@@ -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
|
||||
})
|
||||
}
|
||||
@@ -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]
|
||||
Reference in New Issue
Block a user