This commit is contained in:
Rushabh Mehta 2015-04-02 14:28:32 +05:30
parent 76d475471c
commit f6fa45a735
5 changed files with 24 additions and 15 deletions

View file

@ -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()

View file

@ -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");
}
});

View file

@ -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

View file

@ -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 = [

View file

@ -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;
}
}