|
|
@@ -289,58 +289,6 @@ $.extend(frappe.model, { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
map_current_doc: function(opts) { |
|
|
|
if(opts.get_query_filters) { |
|
|
|
opts.get_query = function() { |
|
|
|
return {filters: opts.get_query_filters}; |
|
|
|
} |
|
|
|
} |
|
|
|
var _map = function() { |
|
|
|
return frappe.call({ |
|
|
|
// Sometimes we hit the limit for URL length of a GET request |
|
|
|
// as we send the full target_doc. Hence this is a POST request. |
|
|
|
type: "POST", |
|
|
|
method: opts.method, |
|
|
|
args: { |
|
|
|
"source_name": opts.source_name, |
|
|
|
"target_doc": cur_frm.doc |
|
|
|
}, |
|
|
|
callback: function(r) { |
|
|
|
if(!r.exc) { |
|
|
|
var doc = frappe.model.sync(r.message); |
|
|
|
cur_frm.refresh(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
if(opts.source_doctype) { |
|
|
|
var d = new frappe.ui.Dialog({ |
|
|
|
title: __("Get From ") + __(opts.source_doctype), |
|
|
|
fields: [ |
|
|
|
{ |
|
|
|
fieldtype: "Link", |
|
|
|
label: __(opts.source_doctype), |
|
|
|
fieldname: opts.source_doctype, |
|
|
|
options: opts.source_doctype, |
|
|
|
get_query: opts.get_query, |
|
|
|
reqd:1 |
|
|
|
}, |
|
|
|
] |
|
|
|
}); |
|
|
|
d.set_primary_action(__('Get Items'), function() { |
|
|
|
var values = d.get_values(); |
|
|
|
if(!values) |
|
|
|
return; |
|
|
|
opts.source_name = values[opts.source_doctype]; |
|
|
|
d.hide(); |
|
|
|
_map(); |
|
|
|
}) |
|
|
|
d.show(); |
|
|
|
} else if(opts.source_name) { |
|
|
|
_map(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|