From 68829ab2e6d2ca8238bd9d5bd44844e032cee089 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Thu, 21 Jan 2021 19:06:33 +0100 Subject: [PATCH 001/106] feat: default_email_template --- frappe/core/doctype/doctype/doctype.json | 13 ++++++++++++- frappe/public/js/frappe/views/communication.js | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/frappe/core/doctype/doctype/doctype.json b/frappe/core/doctype/doctype/doctype.json index 215ef8cd62..55c74a4e63 100644 --- a/frappe/core/doctype/doctype/doctype.json +++ b/frappe/core/doctype/doctype/doctype.json @@ -55,6 +55,8 @@ "show_preview_popup", "show_name_in_global_search", "email_settings_sb", + "default_email_template", + "column_break_51", "email_append_to", "sender_field", "subject_field", @@ -528,6 +530,15 @@ "fieldname": "index_web_pages_for_search", "fieldtype": "Check", "label": "Index Web Pages for Search" + }, + { + "fieldname": "default_email_template", + "fieldtype": "Data", + "label": "Default Email Template" + }, + { + "fieldname": "column_break_51", + "fieldtype": "Column Break" } ], "icon": "fa fa-bolt", @@ -609,7 +620,7 @@ "link_fieldname": "reference_doctype" } ], - "modified": "2020-09-24 13:13:58.227153", + "modified": "2021-01-21 18:09:47.135696", "modified_by": "Administrator", "module": "Core", "name": "DocType", diff --git a/frappe/public/js/frappe/views/communication.js b/frappe/public/js/frappe/views/communication.js index c69be04347..7b9668a96e 100755 --- a/frappe/public/js/frappe/views/communication.js +++ b/frappe/public/js/frappe/views/communication.js @@ -159,6 +159,7 @@ frappe.views.CommunicationComposer = Class.extend({ this.setup_last_edited_communication(); this.setup_email_template(); + this.dialog.set_value("email_template", this.frm.meta.default_email_template || ''); this.dialog.set_value("recipients", this.recipients || ''); this.dialog.set_value("cc", this.cc || ''); this.dialog.set_value("bcc", this.bcc || ''); From 2618ee74d898f48a0899691c045e2ce1e0a4b4da Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Wed, 27 Jan 2021 18:55:54 +0100 Subject: [PATCH 002/106] feat: add default_email_template to Customize Form --- .../doctype/customize_form/customize_form.json | 13 ++++++++++++- .../custom/doctype/customize_form/customize_form.py | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/frappe/custom/doctype/customize_form/customize_form.json b/frappe/custom/doctype/customize_form/customize_form.json index ff102b3c08..dee2dfce0d 100644 --- a/frappe/custom/doctype/customize_form/customize_form.json +++ b/frappe/custom/doctype/customize_form/customize_form.json @@ -31,6 +31,8 @@ "show_preview_popup", "image_view", "email_settings_section", + "default_email_template", + "column_break_26", "email_append_to", "sender_field", "subject_field", @@ -261,6 +263,15 @@ "fieldtype": "Table", "label": "Actions", "options": "DocType Action" + }, + { + "fieldname": "default_email_template", + "fieldtype": "Data", + "label": "Default Email Template" + }, + { + "fieldname": "column_break_26", + "fieldtype": "Column Break" } ], "hide_toolbar": 1, @@ -269,7 +280,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2020-09-24 14:16:49.594012", + "modified": "2021-01-27 18:26:59.705786", "modified_by": "Administrator", "module": "Custom", "name": "Customize Form", diff --git a/frappe/custom/doctype/customize_form/customize_form.py b/frappe/custom/doctype/customize_form/customize_form.py index 82513783c7..0718f5d84c 100644 --- a/frappe/custom/doctype/customize_form/customize_form.py +++ b/frappe/custom/doctype/customize_form/customize_form.py @@ -479,6 +479,7 @@ doctype_properties = { 'allow_auto_repeat': 'Check', 'allow_import': 'Check', 'show_preview_popup': 'Check', + 'default_email_template': 'Data', 'email_append_to': 'Check', 'subject_field': 'Data', 'sender_field': 'Data' From b14b28d7650001af5d7812bda07c15cb74e883ff Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Wed, 27 Jan 2021 18:59:00 +0100 Subject: [PATCH 003/106] fix: check if frm is available Prevents error when creating new Communication from list view. --- frappe/public/js/frappe/views/communication.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/views/communication.js b/frappe/public/js/frappe/views/communication.js index 7b9668a96e..073ce44206 100755 --- a/frappe/public/js/frappe/views/communication.js +++ b/frappe/public/js/frappe/views/communication.js @@ -159,7 +159,10 @@ frappe.views.CommunicationComposer = Class.extend({ this.setup_last_edited_communication(); this.setup_email_template(); - this.dialog.set_value("email_template", this.frm.meta.default_email_template || ''); + if ('frm' in this) { + this.dialog.set_value("email_template", this.frm.meta.default_email_template || ''); + } + this.dialog.set_value("recipients", this.recipients || ''); this.dialog.set_value("cc", this.cc || ''); this.dialog.set_value("bcc", this.bcc || ''); From fa39484571d993ed5562149b6c85615e39cdc27b Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Wed, 27 Jan 2021 18:59:47 +0100 Subject: [PATCH 004/106] fix: check if email_template is set Prevents error on empty email_template. --- frappe/public/js/frappe/views/communication.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frappe/public/js/frappe/views/communication.js b/frappe/public/js/frappe/views/communication.js index 073ce44206..c5c6cdced9 100755 --- a/frappe/public/js/frappe/views/communication.js +++ b/frappe/public/js/frappe/views/communication.js @@ -232,6 +232,9 @@ frappe.views.CommunicationComposer = Class.extend({ this.dialog.fields_dict["email_template"].df.onchange = () => { var email_template = me.dialog.fields_dict.email_template.get_value(); + if (email_template === '') { + return; + } var prepend_reply = function(reply) { if(me.reply_added===email_template) { From 885d198622703ef50b0f6443f3a00ee76b0c2d58 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Thu, 4 Feb 2021 12:20:12 +0100 Subject: [PATCH 005/106] fix: don't apply default email template for reply --- frappe/public/js/frappe/views/communication.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frappe/public/js/frappe/views/communication.js b/frappe/public/js/frappe/views/communication.js index f1feb4f6a3..66e050f3d1 100755 --- a/frappe/public/js/frappe/views/communication.js +++ b/frappe/public/js/frappe/views/communication.js @@ -196,10 +196,6 @@ frappe.views.CommunicationComposer = Class.extend({ this.setup_last_edited_communication(); this.setup_email_template(); - if ('frm' in this) { - this.dialog.set_value("email_template", this.frm.meta.default_email_template || ''); - } - this.dialog.set_value("recipients", this.recipients || ''); this.dialog.set_value("cc", this.cc || ''); this.dialog.set_value("bcc", this.bcc || ''); @@ -210,6 +206,11 @@ frappe.views.CommunicationComposer = Class.extend({ this.dialog.fields_dict.subject.set_value(this.subject || ''); this.setup_earlier_reply(); + + if ('frm' in this && !this.is_a_reply) { + // set default email template for the first email in a document + this.dialog.set_value("email_template", this.frm.meta.default_email_template || ''); + } }, setup_subject_and_recipients: function() { From cb211c6272669662d1012aa7331538ba856c1579 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Mon, 8 Feb 2021 12:51:47 +0100 Subject: [PATCH 006/106] fix: signature should be an empty string by default (would become undefined if the server message was empty) --- frappe/public/js/frappe/views/communication.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/views/communication.js b/frappe/public/js/frappe/views/communication.js index 66e050f3d1..5329967e12 100755 --- a/frappe/public/js/frappe/views/communication.js +++ b/frappe/public/js/frappe/views/communication.js @@ -726,7 +726,7 @@ frappe.views.CommunicationComposer = Class.extend({ if (!signature) { const res = await this.get_default_outgoing_email_account_signature(); - signature = res.message.signature; + signature = res.message.signature || ""; } if(!frappe.utils.is_html(signature)) { From 87326625fed3f0ce0b72977f2e988783e59741c8 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Mon, 22 Mar 2021 12:31:58 +0100 Subject: [PATCH 007/106] fix: make Default Email Template a link field --- frappe/core/doctype/doctype/doctype.json | 7 ++++--- frappe/custom/doctype/customize_form/customize_form.json | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/frappe/core/doctype/doctype/doctype.json b/frappe/core/doctype/doctype/doctype.json index 7bf91892ee..fb24c095f3 100644 --- a/frappe/core/doctype/doctype/doctype.json +++ b/frappe/core/doctype/doctype/doctype.json @@ -533,8 +533,9 @@ }, { "fieldname": "default_email_template", - "fieldtype": "Data", - "label": "Default Email Template" + "fieldtype": "Link", + "label": "Default Email Template", + "options": "Email Template" }, { "fieldname": "column_break_51", @@ -620,7 +621,7 @@ "link_fieldname": "reference_doctype" } ], - "modified": "2021-02-23 15:10:09.227205", + "modified": "2021-03-22 12:26:41.031135", "modified_by": "Administrator", "module": "Core", "name": "DocType", diff --git a/frappe/custom/doctype/customize_form/customize_form.json b/frappe/custom/doctype/customize_form/customize_form.json index dee2dfce0d..f8db73137e 100644 --- a/frappe/custom/doctype/customize_form/customize_form.json +++ b/frappe/custom/doctype/customize_form/customize_form.json @@ -266,8 +266,9 @@ }, { "fieldname": "default_email_template", - "fieldtype": "Data", - "label": "Default Email Template" + "fieldtype": "Link", + "label": "Default Email Template", + "options": "Email Template" }, { "fieldname": "column_break_26", @@ -280,7 +281,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2021-01-27 18:26:59.705786", + "modified": "2021-03-22 12:27:15.462727", "modified_by": "Administrator", "module": "Custom", "name": "Customize Form", From 6df8479525c4e7af1cfd3b0428700c40cad0c9a9 Mon Sep 17 00:00:00 2001 From: Richard Case Date: Thu, 11 Mar 2021 01:18:16 +0000 Subject: [PATCH 008/106] fix: build priority on computers with low memory fixes:frappe/bench#1135 --- frappe/commands/__init__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frappe/commands/__init__.py b/frappe/commands/__init__.py index b9ae02e112..61ee62d352 100644 --- a/frappe/commands/__init__.py +++ b/frappe/commands/__init__.py @@ -62,11 +62,24 @@ def popen(command, *args, **kwargs): if env: env = dict(environ, **env) + def set_low_prio(): + import psutil + if psutil.LINUX: + psutil.Process().nice(19) + psutil.Process().ionice(psutil.IOPRIO_CLASS_IDLE) + elif psutil.WINDOWS: + psutil.Process().nice(psutil.IDLE_PRIORITY_CLASS) + psutil.Process().ionice(psutil.IOPRIO_VERYLOW) + else: + psutil.Process().nice(19) + # ionice not supported + proc = subprocess.Popen(command, stdout=None if output else subprocess.PIPE, stderr=None if output else subprocess.PIPE, shell=shell, cwd=cwd, + preexec_fn=set_low_prio, env=env ) From 5290b4c65f15642c5bc7c84d70fcfc4c14c3d883 Mon Sep 17 00:00:00 2001 From: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Date: Sat, 27 Mar 2021 15:01:37 +0100 Subject: [PATCH 009/106] fix: add back column break that was lost in merge --- frappe/custom/doctype/customize_form/customize_form.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frappe/custom/doctype/customize_form/customize_form.json b/frappe/custom/doctype/customize_form/customize_form.json index fc74f0881b..442b8dbb31 100644 --- a/frappe/custom/doctype/customize_form/customize_form.json +++ b/frappe/custom/doctype/customize_form/customize_form.json @@ -272,6 +272,10 @@ "label": "Default Email Template", "options": "Email Template" }, + { + "fieldname": "column_break_26", + "fieldtype": "Column Break" + }, { "collapsible": 1, "fieldname": "naming_section", @@ -312,4 +316,4 @@ "sort_field": "modified", "sort_order": "DESC", "track_changes": 1 -} \ No newline at end of file +} From 08d8e67946d02d01bf4e385171e8f2df5c8cebed Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Tue, 6 Apr 2021 14:56:28 +0530 Subject: [PATCH 010/106] fix(backups): ensure delete_temp_backups always respects config --- frappe/utils/backups.py | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/frappe/utils/backups.py b/frappe/utils/backups.py index 77c5761527..3c14cd9d5e 100644 --- a/frappe/utils/backups.py +++ b/frappe/utils/backups.py @@ -15,7 +15,7 @@ import click # imports - module imports import frappe from frappe import _, conf -from frappe.utils import get_file_size, get_url, now, now_datetime +from frappe.utils import get_file_size, get_url, now, now_datetime, cint # backup variable for backwards compatibility verbose = False @@ -474,29 +474,6 @@ download only after 24 hours.""" % { return recipient_list -@frappe.whitelist() -def get_backup(): - """ - This function is executed when the user clicks on - Toos > Download Backup - """ - delete_temp_backups() - odb = BackupGenerator( - frappe.conf.db_name, - frappe.conf.db_name, - frappe.conf.db_password, - db_host=frappe.db.host, - db_type=frappe.conf.db_type, - db_port=frappe.conf.db_port, - ) - odb.get_backup() - recipient_list = odb.send_email() - frappe.msgprint( - _( - "Download link for your backup will be emailed on the following email address: {0}" - ).format(", ".join(recipient_list)) - ) - @frappe.whitelist() def fetch_latest_backups(partial=False): """Fetches paths of the latest backup taken in the last 30 days @@ -570,7 +547,7 @@ def new_backup( force=False, verbose=False, ): - delete_temp_backups(older_than=frappe.conf.keep_backups_for_hours or 24) + delete_temp_backups() odb = BackupGenerator( frappe.conf.db_name, frappe.conf.db_name, @@ -593,10 +570,11 @@ def new_backup( return odb -def delete_temp_backups(older_than=24): +def delete_temp_backups(): """ Cleans up the backup_link_path directory by deleting files older than 24 hours """ + older_than = cint(frappe.conf.keep_backups_for_hours) or 24 backup_path = get_backup_path() if os.path.exists(backup_path): file_list = os.listdir(get_backup_path()) From c6497abcd143946c72d0b04fdc029b0edd853df3 Mon Sep 17 00:00:00 2001 From: walstanb Date: Fri, 9 Apr 2021 13:06:58 +0530 Subject: [PATCH 011/106] fix: minor changes --- frappe/utils/backups.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frappe/utils/backups.py b/frappe/utils/backups.py index 3c14cd9d5e..9a6747a0cf 100644 --- a/frappe/utils/backups.py +++ b/frappe/utils/backups.py @@ -570,11 +570,11 @@ def new_backup( return odb -def delete_temp_backups(): +def delete_temp_backups(older_than=24): """ - Cleans up the backup_link_path directory by deleting files older than 24 hours + Cleans up the backup_link_path directory by deleting older files """ - older_than = cint(frappe.conf.keep_backups_for_hours) or 24 + older_than = cint(frappe.conf.keep_backups_for_hours) or older_than backup_path = get_backup_path() if os.path.exists(backup_path): file_list = os.listdir(get_backup_path()) From 6004125469cc78053e753546324a9d145e7f1161 Mon Sep 17 00:00:00 2001 From: "hasnain2808@gmail.com" Date: Wed, 14 Apr 2021 13:52:43 +0530 Subject: [PATCH 012/106] feat: allow button of different sizes in df --- frappe/public/js/frappe/form/controls/button.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/form/controls/button.js b/frappe/public/js/frappe/form/controls/button.js index b44c9d9dcd..d09e9c3a95 100644 --- a/frappe/public/js/frappe/form/controls/button.js +++ b/frappe/public/js/frappe/form/controls/button.js @@ -6,7 +6,10 @@ frappe.ui.form.ControlButton = frappe.ui.form.ControlData.extend({ make_input: function() { var me = this; const btn_type = this.df.primary ? 'btn-primary': 'btn-default'; - this.$input = $(`