diff --git a/frappe/desk/search.py b/frappe/desk/search.py index 853003110e..a03b2352a7 100644 --- a/frappe/desk/search.py +++ b/frappe/desk/search.py @@ -39,9 +39,9 @@ def search_widget(doctype, txt, query=None, searchfield=None, start=0, searchfield, start, page_len, filters) else: if query: + frappe.throw("This query style is discontinued") # custom query - frappe.response["values"] = frappe.db.sql(scrub_custom_query(query, - searchfield, txt)) + # frappe.response["values"] = frappe.db.sql(scrub_custom_query(query, searchfield, txt)) else: if isinstance(filters, dict): filters_items = filters.items() diff --git a/frappe/email/doctype/email_account/email_account.js b/frappe/email/doctype/email_account/email_account.js index 0852977f19..ae4ba30e58 100644 --- a/frappe/email/doctype/email_account/email_account.js +++ b/frappe/email/doctype/email_account/email_account.js @@ -25,19 +25,22 @@ email_defaults = { }, }; -frappe.ui.form.on("Email Account", "service", function(frm) { - if(frm.doc.service && email_defaults[frm.doc.service]) { +frappe.ui.form.on("Email Account", { + service: function(frm) { $.each(email_defaults[frm.doc.service], function(key, value) { frm.set_value(key, value); }) - } -}); - -frappe.ui.form.on("Email Account", "email_id", function(frm) { - if(!frm.doc.email_account_name) { - frm.set_value("email_account_name", - (frm.doc.service ? frm.doc.service + " " : "") - + toTitle(frm.doc.email_id.split("@")[0].replace(/[._]/g, " "))); + }, + email_id: function(frm) { + if(!frm.doc.email_account_name) { + frm.set_value("email_account_name", + (frm.doc.service ? frm.doc.service + " " : "") + + toTitle(frm.doc.email_id.split("@")[0].replace(/[._]/g, " "))); + } + }, + onload: function(frm) { + frm.set_df_property("append_to", "only_select", true); + frm.set_query("append_to", "frappe.email.doctype.email_account.email_account.get_append_to"); } }); diff --git a/frappe/email/doctype/email_account/email_account.py b/frappe/email/doctype/email_account/email_account.py index 1dafa5f5cb..724d5bcbcb 100644 --- a/frappe/email/doctype/email_account/email_account.py +++ b/frappe/email/doctype/email_account/email_account.py @@ -234,6 +234,11 @@ class EmailAccount(Document): """Clear communications where email account is linked""" frappe.db.sql("update `tabCommunication` set email_account='' where email_account=%s", self.name) +@frappe.whitelist() +def get_append_to(doctype, txt, searchfield, start, page_len, filters): + if not txt: txt = "" + return [[d] for d in frappe.get_hooks("email_append_to") if txt in d] + def pull(now=False): """Will be called via scheduler, pull emails from all enabled POP3 email accounts.""" import frappe.tasks diff --git a/frappe/hooks.py b/frappe/hooks.py index f51aea90f1..ef4d4b2530 100644 --- a/frappe/hooks.py +++ b/frappe/hooks.py @@ -57,6 +57,8 @@ before_tests = "frappe.utils.install.before_tests" website_generators = ["Web Page", "Blog Post", "Blog Category", "Web Form"] +email_append_to = ["Event", "ToDo", "Communication"] + # login on_session_creation = [ diff --git a/frappe/public/js/legacy/clientscriptAPI.js b/frappe/public/js/legacy/clientscriptAPI.js index ed8c5d79dc..d853cfef4e 100644 --- a/frappe/public/js/legacy/clientscriptAPI.js +++ b/frappe/public/js/legacy/clientscriptAPI.js @@ -183,11 +183,10 @@ _f.Frm.prototype.get_files = function() { } _f.Frm.prototype.set_query = function(fieldname, opt1, opt2) { - var func = (typeof opt1=="function") ? opt1 : opt2; if(opt2) { - this.fields_dict[opt1].grid.get_field(fieldname).get_query = func; + this.fields_dict[opt1].grid.get_field(fieldname).get_query = opt2; } else { - this.fields_dict[fieldname].get_query = func; + this.fields_dict[fieldname].get_query = opt1; } }