From ead70561670976a2e1b68a18b45759df0c3abb05 Mon Sep 17 00:00:00 2001 From: mbauskar Date: Tue, 19 Sep 2017 15:56:33 +0530 Subject: [PATCH 1/7] [hotfix] set the email account for outgoing emails --- frappe/core/doctype/communication/email.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frappe/core/doctype/communication/email.py b/frappe/core/doctype/communication/email.py index cbc9c5a9bb..894f324d2b 100755 --- a/frappe/core/doctype/communication/email.py +++ b/frappe/core/doctype/communication/email.py @@ -233,6 +233,8 @@ def prepare_to_notify(doc, print_html=None, print_format=None, attachments=None) doc.content += get_attach_link(doc, print_format) set_incoming_outgoing_accounts(doc) + if doc.sent_or_received == "Sent": + doc.db_set("email_account", doc.outgoing_email_account.name) if not doc.sender: doc.sender = doc.outgoing_email_account.email_id From bcecf23772ca04fbd65e96273f899bef62bb1bad Mon Sep 17 00:00:00 2001 From: mbauskar Date: Wed, 20 Sep 2017 11:51:09 +0530 Subject: [PATCH 2/7] [minor] moved code to set_incoming_outgoing_accounts method --- frappe/core/doctype/communication/email.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frappe/core/doctype/communication/email.py b/frappe/core/doctype/communication/email.py index 894f324d2b..b8a8b4ec30 100755 --- a/frappe/core/doctype/communication/email.py +++ b/frappe/core/doctype/communication/email.py @@ -233,8 +233,6 @@ def prepare_to_notify(doc, print_html=None, print_format=None, attachments=None) doc.content += get_attach_link(doc, print_format) set_incoming_outgoing_accounts(doc) - if doc.sent_or_received == "Sent": - doc.db_set("email_account", doc.outgoing_email_account.name) if not doc.sender: doc.sender = doc.outgoing_email_account.email_id @@ -291,6 +289,9 @@ def set_incoming_outgoing_accounts(doc): {"default_outgoing": 1, "enable_outgoing": 1}, ["email_id", "always_use_account_email_id_as_sender", "name", "send_unsubscribe_message"], as_dict=True) or frappe._dict() + if doc.sent_or_received == "Sent": + doc.db_set("email_account", doc.outgoing_email_account.name) + def get_recipients(doc, fetched_from_email_account=False): """Build a list of email addresses for To""" # [EDGE CASE] doc.recipients can be None when an email is sent as BCC From 47677c055cd02303591a8e1515296fdaa6cba22b Mon Sep 17 00:00:00 2001 From: Makarand Bauskar Date: Thu, 21 Sep 2017 12:32:20 +0530 Subject: [PATCH 3/7] [minor] refactor mark as read and mark as unread (#4154) * [minor] refresh inbox view on mark as read or mark as unread * [minor] refactor mark as read and mark as unread * [minor] don't update modified datetime while settings _seen --- .../doctype/communication/communication.py | 5 +-- .../communication/communication_list.js | 6 +-- .../email_flag_queue/email_flag_queue.json | 36 +++------------- frappe/email/inbox.py | 42 +++++++++++-------- frappe/public/js/frappe/ui/base_list.js | 2 +- 5 files changed, 36 insertions(+), 55 deletions(-) diff --git a/frappe/core/doctype/communication/communication.py b/frappe/core/doctype/communication/communication.py index aa9a7c3a4e..db00a45ff6 100644 --- a/frappe/core/doctype/communication/communication.py +++ b/frappe/core/doctype/communication/communication.py @@ -26,17 +26,16 @@ class Communication(Document): if self.communication_type == "Communication" and self.communication_medium == "Email" \ and self.sent_or_received == "Received" and self.uid and self.uid != -1: - flag = frappe.db.get_value("Email Flag Queue", { + email_flag_queue = frappe.db.get_value("Email Flag Queue", { "communication": self.name, "is_completed": 0}) - if flag: + if email_flag_queue: return frappe.get_doc({ "doctype": "Email Flag Queue", "action": "Read", "communication": self.name, - "flag": "(\\SEEN)", "uid": self.uid, "email_account": self.email_account }).insert(ignore_permissions=True) diff --git a/frappe/core/doctype/communication/communication_list.js b/frappe/core/doctype/communication/communication_list.js index 0df5bfb9b9..a7e9f0569c 100644 --- a/frappe/core/doctype/communication/communication_list.js +++ b/frappe/core/doctype/communication/communication_list.js @@ -9,13 +9,13 @@ frappe.listview_settings['Communication'] = { filters: [["status", "=", "Open"]], onload: function(list_view) { - var method = "frappe.email.inbox.create_email_flag_queue" + let method = "frappe.email.inbox.create_email_flag_queue" list_view.page.add_menu_item(__("Mark as Read"), function() { - list_view.call_for_selected_items(method, { action: "Read" }) + list_view.call_for_selected_items(method, { action: "Read" }); }); list_view.page.add_menu_item(__("Mark as Unread"), function() { - list_view.call_for_selected_items(method, { action: "Unread" }) + list_view.call_for_selected_items(method, { action: "Unread" }); }); }, diff --git a/frappe/email/doctype/email_flag_queue/email_flag_queue.json b/frappe/email/doctype/email_flag_queue/email_flag_queue.json index 3ac86f0f75..165e8f9ea9 100644 --- a/frappe/email/doctype/email_flag_queue/email_flag_queue.json +++ b/frappe/email/doctype/email_flag_queue/email_flag_queue.json @@ -12,6 +12,7 @@ "editable_grid": 0, "fields": [ { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -41,6 +42,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -71,6 +73,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -101,35 +104,7 @@ "unique": 0 }, { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "flag", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Flag", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -159,6 +134,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -198,7 +174,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-03-15 13:09:28.002266", + "modified": "2017-09-20 15:27:12.142079", "modified_by": "Administrator", "module": "Email", "name": "Email Flag Queue", diff --git a/frappe/email/inbox.py b/frappe/email/inbox.py index 757a0245e1..a3847dc0e6 100644 --- a/frappe/email/inbox.py +++ b/frappe/email/inbox.py @@ -46,48 +46,54 @@ def get_email_accounts(user=None): } @frappe.whitelist() -def create_email_flag_queue(names, action, flag="(\\Seen)"): +def create_email_flag_queue(names, action): """ create email flag queue to mark email either as read or unread """ - class Found(Exception): - pass + def mark_as_seen_unseen(name, action): + doc = frappe.get_doc("Communication", name) + if action == "Read": + doc.add_seen() + else: + _seen = json.loads(doc._seen or '[]') + _seen = [user for user in _seen if frappe.session.user != user] + doc.db_set('_seen', json.dumps(_seen), update_modified=False) - if not all([names, action, flag]): + if not all([names, action]): return for name in json.loads(names or []): uid, seen_status, email_account = frappe.db.get_value("Communication", name, ["ifnull(uid, -1)", "ifnull(seen, 0)", "email_account"]) + # can not mark email SEEN or UNSEEN without uid if not uid or uid == -1: continue seen = 1 if action == "Read" else 0 # check if states are correct if (action =='Read' and seen_status == 0) or (action =='Unread' and seen_status == 1): - try: - queue = frappe.db.sql("""select name, action, flag from `tabEmail Flag Queue` - where communication = %(name)s""", {"name":name}, as_dict=True) - for q in queue: - # is same email with same flag - if q.flag == flag: - # to prevent flag local and server states being out of sync - if q.action != action: - frappe.delete_doc("Email Flag Queue", q.name) - raise Found + create_new = True + email_flag_queue = frappe.db.sql("""select name, action from `tabEmail Flag Queue` + where communication = %(name)s and is_completed=0""", {"name":name}, as_dict=True) + for queue in email_flag_queue: + if queue.action != action: + frappe.delete_doc("Email Flag Queue", queue.name, ignore_permissions=True) + elif queue.action == action: + # Read or Unread request for email is already available + create_new = False + + if create_new: flag_queue = frappe.get_doc({ "uid": uid, - "flag": flag, "action": action, "communication": name, "doctype": "Email Flag Queue", "email_account": email_account }) - flag_queue.save(ignore_permissions=True); + flag_queue.save(ignore_permissions=True) frappe.db.set_value("Communication", name, "seen", seen, update_modified=False) - except Found: - pass + mark_as_seen_unseen(name, action) @frappe.whitelist() def mark_as_trash(communication): diff --git a/frappe/public/js/frappe/ui/base_list.js b/frappe/public/js/frappe/ui/base_list.js index 30a51bfb4b..0d3b1957e8 100644 --- a/frappe/public/js/frappe/ui/base_list.js +++ b/frappe/public/js/frappe/ui/base_list.js @@ -524,7 +524,7 @@ frappe.ui.BaseList = Class.extend({ if (me.list_header) { me.list_header.find(".list-select-all").prop("checked", false); } - me.refresh(); + me.refresh(true); } } }); From 69eb8934c0969400a5ee707eb0fb972480d124e5 Mon Sep 17 00:00:00 2001 From: mbauskar Date: Thu, 21 Sep 2017 17:55:10 +0530 Subject: [PATCH 4/7] [hotfix] refresh dependancy after values are set in doc --- frappe/public/js/frappe/ui/field_group.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/ui/field_group.js b/frappe/public/js/frappe/ui/field_group.js index 5df46c55ef..4ddff384d0 100644 --- a/frappe/public/js/frappe/ui/field_group.js +++ b/frappe/public/js/frappe/ui/field_group.js @@ -33,11 +33,15 @@ frappe.ui.FieldGroup = frappe.ui.form.Layout.extend({ } $(this.body).find('input').on('change', function() { - me.refresh_dependency(); + frappe.run_serially([ + () => me.refresh_dependency() + ]); }) $(this.body).find('select').on("change", function() { - me.refresh_dependency(); + frappe.run_serially([ + () => me.refresh_dependency() + ]); }) } }, From 455179b8729b4e51da1db357b795174254bac90b Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 22 Sep 2017 12:40:22 +0530 Subject: [PATCH 5/7] Update field_group.js --- frappe/public/js/frappe/ui/field_group.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/frappe/public/js/frappe/ui/field_group.js b/frappe/public/js/frappe/ui/field_group.js index 4ddff384d0..087c5c1beb 100644 --- a/frappe/public/js/frappe/ui/field_group.js +++ b/frappe/public/js/frappe/ui/field_group.js @@ -32,17 +32,13 @@ frappe.ui.FieldGroup = frappe.ui.form.Layout.extend({ this.catch_enter_as_submit(); } - $(this.body).find('input').on('change', function() { + $(this.body).find('input, select').on('change', function() { frappe.run_serially([ + () => frappe.timeout(0.1), () => me.refresh_dependency() ]); - }) + }); - $(this.body).find('select').on("change", function() { - frappe.run_serially([ - () => me.refresh_dependency() - ]); - }) } }, add_fields: function(fields) { From 57dfa412af8411d22c05d1d5f4e7415eea1e2a89 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Sat, 23 Sep 2017 16:09:04 +0530 Subject: [PATCH 6/7] [fix] web form datepicker, trigger change event --- frappe/website/js/web_form.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frappe/website/js/web_form.js b/frappe/website/js/web_form.js index 33e2ed3b87..8d51c834d1 100644 --- a/frappe/website/js/web_form.js +++ b/frappe/website/js/web_form.js @@ -350,7 +350,7 @@ frappe.ready(function() { } }); } - }) + }); // setup datepicker in all inputs within the given element var setup_date_picker = function(ele) { @@ -362,7 +362,10 @@ frappe.ready(function() { $dates.datepicker({ language: "en", autoClose: true, - dateFormat: frappe.datepicker_format + dateFormat: frappe.datepicker_format, + onSelect: function(date, date_str, e) { + e.$el.trigger('change'); + }, }); // initialize dates from YYYY-MM-DD to user format @@ -408,7 +411,7 @@ frappe.ready(function() { }); }); - } + }; setup_text_editor(); }); From 552abc9db74e6317a27ace8bc260a7f0e939e89a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 25 Sep 2017 16:59:07 +0600 Subject: [PATCH 7/7] bumped to version 8.10.9 --- frappe/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index 6d2ca90e42..cde8ef4adf 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -14,7 +14,7 @@ import os, sys, importlib, inspect, json from .exceptions import * from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template -__version__ = '8.10.8' +__version__ = '8.10.9' __title__ = "Frappe Framework" local = Local()