Merge pull request #7103 from bhupennewalkar1337/delivery-note-fix

[Fix] Disallow same items to be fetched multiple times in sales invoice
This commit is contained in:
Nabin Hait 2016-12-01 18:07:28 +05:30 committed by GitHub
commit feec1abb6e

View File

@ -143,8 +143,35 @@ erpnext.utils.map_current_doc = function(opts) {
if(!cur_frm.doc.items[0].item_code) {
cur_frm.doc.items = cur_frm.doc.items.splice(1);
}
// find the doctype of the items table
var items_doctype = frappe.meta.get_docfield(cur_frm.doctype, 'items').options;
// find the link fieldname from items table for the given
// source_doctype
var link_fieldname = null;
frappe.get_meta(items_doctype).fields.forEach(function(d) {
if(d.options===opts.source_doctype) link_fieldname = d.fieldname; });
// search in existing items if the source_name is already set
var already_set = false;
$.each(cur_frm.doc.items, function(i, d) {
if(d[link_fieldname]==opts.source_name) {
already_set = true;
return false;
}
});
if(already_set) {
frappe.msgprint(__("You have already selected items from {0} {1}",
[opts.source_doctype, opts.source_name]));
return;
}
}
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.