diff --git a/frappe/email/__init__.py b/frappe/email/__init__.py index e911493de9..f8af08e6df 100644 --- a/frappe/email/__init__.py +++ b/frappe/email/__init__.py @@ -16,8 +16,9 @@ def get_contact_list(txt): return filter(None, frappe.db.sql_list('select email from tabUser where email like %s', ('%' + txt + '%'))) try: - out = filter(None, frappe.db.sql_list("""select email_id from `tabContact` - where `email_id` like %(txt)s order by + out = filter(None, frappe.db.sql_list("""select distinct email_id from `tabContact` + where email_id like %(txt)s or concat(first_name, " ", last_name) like %(txt)s order by + if (locate( %(_txt)s, concat(first_name, " ", last_name)), locate( %(_txt)s, concat(first_name, " ", last_name)), 99999), if (locate( %(_txt)s, email_id), locate( %(_txt)s, email_id), 99999)""", {'txt': "%%%s%%" % frappe.db.escape(txt), '_txt': txt.replace("%", "") diff --git a/frappe/public/js/frappe/views/communication.js b/frappe/public/js/frappe/views/communication.js index 813f188521..46c6302e04 100755 --- a/frappe/public/js/frappe/views/communication.js +++ b/frappe/public/js/frappe/views/communication.js @@ -88,7 +88,7 @@ frappe.views.CommunicationComposer = Class.extend({ if(frappe.boot.email_accounts && frappe.boot.email_accounts.length > 1) { fields = [ {label: __("From"), fieldtype: "Select", reqd: 1, fieldname: "sender", - options: frappe.boot.email_accounts.map(function(d) { return e.email_id; }) } + options: frappe.boot.email_accounts.map(function(e) { return e.email_id; }) } ].concat(fields); } @@ -566,28 +566,29 @@ frappe.views.CommunicationComposer = Class.extend({ item: function(item, input) { return $('