diff --git a/frappe/public/js/frappe/form/controls/currency.js b/frappe/public/js/frappe/form/controls/currency.js index 14cae4a33a..1961985117 100644 --- a/frappe/public/js/frappe/form/controls/currency.js +++ b/frappe/public/js/frappe/form/controls/currency.js @@ -1,4 +1,15 @@ frappe.ui.form.ControlCurrency = frappe.ui.form.ControlFloat.extend({ + eval_expression: function(value) { + if (typeof value === 'string' + && value.match(/^[0-9+-/* ]+$/) + // paresFloat('1,44,000') returns 1.0 + // 1,44,000 are being passed when we paste rows from excel sheet to a table + && value.includes(',')) { + return value.replace(",", ""); + } + return value; + }, + format_for_input: function(value) { var formatted_value = format_number(parseFloat(value), this.get_number_format(), this.get_precision()); return isNaN(parseFloat(value)) ? "" : formatted_value; diff --git a/frappe/public/js/frappe/form/controls/link.js b/frappe/public/js/frappe/form/controls/link.js index cc4d3c952a..f206cd12d8 100644 --- a/frappe/public/js/frappe/form/controls/link.js +++ b/frappe/public/js/frappe/form/controls/link.js @@ -171,6 +171,7 @@ frappe.ui.form.ControlLink = frappe.ui.form.ControlData.extend({ if(!me.$input.is(":focus")) { return; } + r.results = me.merge_duplicates(r.results); // show filter description in awesomplete if (args.filters) { @@ -276,6 +277,23 @@ frappe.ui.form.ControlLink = frappe.ui.form.ControlData.extend({ }); }, + merge_duplicates(results) { + // in case of result like this + // [{value: 'Manufacturer 1', 'description': 'mobile part 1'}, + // {value: 'Manufacturer 1', 'description': 'mobile part 2'}] + // suggestion list has two items with same value (docname) & description + return results.reduce((newArr, currElem) => { + if (newArr.length === 0) return [currElem]; + let element_with_same_value = newArr.find(e => e.value === currElem.value); + if (element_with_same_value) { + element_with_same_value.description += `, ${currElem.description}`; + return [...newArr]; + } + return [...newArr, currElem]; + }, []); + // returns [{value: 'Manufacturer 1', 'description': 'mobile part 1, mobile part 2'}] + }, + get_filter_description(filters) { let doctype = this.get_options(); let filter_array = []; diff --git a/frappe/public/js/frappe/ui/page.html b/frappe/public/js/frappe/ui/page.html index a19529b57c..7f5962f248 100644 --- a/frappe/public/js/frappe/ui/page.html +++ b/frappe/public/js/frappe/ui/page.html @@ -6,7 +6,7 @@