From 3f7469875d96255c9079e93577ca3192fe7bc9ca Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Thu, 29 Apr 2021 15:34:46 +0200 Subject: [PATCH 01/15] fix: default number format for germany --- frappe/geo/country_info.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/geo/country_info.json b/frappe/geo/country_info.json index 1e0ae161bc..7ffdf0a8bf 100644 --- a/frappe/geo/country_info.json +++ b/frappe/geo/country_info.json @@ -953,7 +953,7 @@ "currency_fraction_units": 100, "smallest_currency_fraction_value": 0.01, "currency_symbol": "\u20ac", - "number_format": "#,###.##", + "number_format": "#.###,##", "timezones": [ "Europe/Berlin" ] From 4a5f8dd23dc6bab008b51dbd0ed595aabbe757f6 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Mon, 10 May 2021 12:19:41 +0200 Subject: [PATCH 02/15] fix: ignore lft and rgt when migrating a tree doctype --- frappe/modules/import_file.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frappe/modules/import_file.py b/frappe/modules/import_file.py index 5970eae5ca..6d589c4752 100644 --- a/frappe/modules/import_file.py +++ b/frappe/modules/import_file.py @@ -107,6 +107,10 @@ def import_doc(docdict, force=False, data_import=False, pre_process=None, doc = frappe.get_doc(docdict) + if doc.meta.is_tree: + doc.lft = None + doc.rgt = None + doc.run_method("before_import") doc.flags.ignore_version = ignore_version From cb21e9de84d766bd3e37b4c9bc5f4d88b764808e Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Mon, 10 May 2021 12:39:00 +0200 Subject: [PATCH 03/15] fix: 'Meta' object has no attribute 'is_tree' --- frappe/modules/import_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/modules/import_file.py b/frappe/modules/import_file.py index 6d589c4752..05c019cbd8 100644 --- a/frappe/modules/import_file.py +++ b/frappe/modules/import_file.py @@ -107,7 +107,7 @@ def import_doc(docdict, force=False, data_import=False, pre_process=None, doc = frappe.get_doc(docdict) - if doc.meta.is_tree: + if hasattr(doc.meta, 'is_tree') and getattr(doc.meta, 'is_tree'): doc.lft = None doc.rgt = None From aa06b63eb6da160175d54468cfcacdd8ab35be0d Mon Sep 17 00:00:00 2001 From: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Date: Wed, 12 May 2021 20:54:06 +0200 Subject: [PATCH 04/15] refactor: getattr Co-authored-by: gavin --- frappe/modules/import_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/modules/import_file.py b/frappe/modules/import_file.py index 05c019cbd8..4cef95e758 100644 --- a/frappe/modules/import_file.py +++ b/frappe/modules/import_file.py @@ -107,7 +107,7 @@ def import_doc(docdict, force=False, data_import=False, pre_process=None, doc = frappe.get_doc(docdict) - if hasattr(doc.meta, 'is_tree') and getattr(doc.meta, 'is_tree'): + if getattr(doc.meta, 'is_tree', None): doc.lft = None doc.rgt = None From 52d78ab495f429f6aad6e1f9b67b41fb2ae3cdbe Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Thu, 13 May 2021 15:39:18 +0200 Subject: [PATCH 05/15] fix: don't export "lft" and "rgt" fields --- frappe/core/doctype/data_import/data_import.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/core/doctype/data_import/data_import.py b/frappe/core/doctype/data_import/data_import.py index 1c56f54303..8a95e58709 100644 --- a/frappe/core/doctype/data_import/data_import.py +++ b/frappe/core/doctype/data_import/data_import.py @@ -211,7 +211,7 @@ def export_json( doctype, path, filters=None, or_filters=None, name=None, order_by="creation asc" ): def post_process(out): - del_keys = ("modified_by", "creation", "owner", "idx") + del_keys = ("modified_by", "creation", "owner", "idx", "lft", "rgt") for doc in out: for key in del_keys: if key in doc: From 3632a322726adafc8c1cdfe08c8cb8acc2822450 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Thu, 13 May 2021 15:59:39 +0200 Subject: [PATCH 06/15] fix: print warning and add comments --- frappe/core/doctype/data_import/data_import.py | 5 +++++ frappe/modules/import_file.py | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/frappe/core/doctype/data_import/data_import.py b/frappe/core/doctype/data_import/data_import.py index 8a95e58709..7e8374a0a2 100644 --- a/frappe/core/doctype/data_import/data_import.py +++ b/frappe/core/doctype/data_import/data_import.py @@ -211,6 +211,11 @@ def export_json( doctype, path, filters=None, or_filters=None, name=None, order_by="creation asc" ): def post_process(out): + # Note on Tree DocTypes: + # The tree structure is maintained in the database via the fields "lft" + # and "rgt". They are automatically set and kept up-to-date. Importing + # them would destroy any existing tree structure. For this reason they + # are not exported as well. del_keys = ("modified_by", "creation", "owner", "idx", "lft", "rgt") for doc in out: for key in del_keys: diff --git a/frappe/modules/import_file.py b/frappe/modules/import_file.py index 4cef95e758..fdfd00404c 100644 --- a/frappe/modules/import_file.py +++ b/frappe/modules/import_file.py @@ -107,7 +107,12 @@ def import_doc(docdict, force=False, data_import=False, pre_process=None, doc = frappe.get_doc(docdict) - if getattr(doc.meta, 'is_tree', None): + # Note on Tree DocTypes: + # The tree structure is maintained in the database via the fields "lft" and + # "rgt". They are automatically set and kept up-to-date. Importing them + # would destroy any existing tree structure. + if getattr(doc.meta, 'is_tree', None) and any([doc.lft, doc.rgt]): + print('Ignoring values of `lft` and `rgt` for {} "{}"'.format(doc.doctype, doc.name)) doc.lft = None doc.rgt = None From 16ff2de946ab3612bb2e852d6575b91e06811eda Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Thu, 20 May 2021 20:22:14 +0530 Subject: [PATCH 07/15] fix: Make bundled asset URL absolute always --- frappe/utils/jinja_globals.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frappe/utils/jinja_globals.py b/frappe/utils/jinja_globals.py index 625d2e6cd5..347d52dc57 100644 --- a/frappe/utils/jinja_globals.py +++ b/frappe/utils/jinja_globals.py @@ -81,9 +81,10 @@ def include_style(path): def bundled_asset(path): from frappe.utils import get_assets_json + from frappe.website.utils import abs_url - if path.startswith("/assets") or ".bundle." not in path: - return path + if ".bundle." in path and not path.startswith("/assets"): + bundled_assets = get_assets_json() + path = bundled_assets.get(path) or path - bundled_assets = get_assets_json() - return bundled_assets.get(path) or path + return abs_url(path) From e8d79030f79375f704a9716e8be9c7b26a1e0a3f Mon Sep 17 00:00:00 2001 From: Joseph Marie Alba Date: Fri, 21 May 2021 15:44:33 +0800 Subject: [PATCH 08/15] fix: Python 3 issue on re (#13230) Python 3 interprets string literals as Unicode strings, and therefore \s and \g are treated as escaped Unicode characters. Fix: Declare RegEx pattern as a raw string instead by prepending r --- frappe/translate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/translate.py b/frappe/translate.py index 1d8b1234c7..b9dd5e263a 100644 --- a/frappe/translate.py +++ b/frappe/translate.py @@ -650,7 +650,7 @@ def write_csv_file(path, app_messages, lang_dict): t = lang_dict.get(message, '') # strip whitespaces - translated_string = re.sub('{\s?([0-9]+)\s?}', "{\g<1>}", t) + translated_string = re.sub(r'{\s?([0-9]+)\s?}', r"{\g<1>}", t) if translated_string: w.writerow([message, translated_string, context]) From ff21cd4fcea8360321ad7a0d2f44f042209af8e7 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Fri, 21 May 2021 16:09:43 +0530 Subject: [PATCH 09/15] fix: set correct default redis async broker in node_utils --- node_utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node_utils.js b/node_utils.js index b87c99a07c..ac2f96f655 100644 --- a/node_utils.js +++ b/node_utils.js @@ -6,7 +6,7 @@ const bench_path = path.resolve(__dirname, '..', '..'); function get_conf() { // defaults var conf = { - redis_async_broker_port: 12311, + redis_async_broker_port: 'redis://localhost:12311', socketio_port: 3000 }; From 07cdab39022c8efdb6617ba07c241b246968325e Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 21 May 2021 17:01:28 +0530 Subject: [PATCH 10/15] fix: Add a command to properly extend class methods --- frappe/public/js/frappe/form/script_manager.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frappe/public/js/frappe/form/script_manager.js b/frappe/public/js/frappe/form/script_manager.js index 420cda5a82..7e65df65ed 100644 --- a/frappe/public/js/frappe/form/script_manager.js +++ b/frappe/public/js/frappe/form/script_manager.js @@ -3,6 +3,13 @@ frappe.provide("frappe.ui.form.handlers"); +window.extend_cscript = (cscript, controller_object) => { + $.extend(cscript, controller_object); + if (controller_object.__proto__) { + cscript.__proto__ = controller_object.__proto__; + } +}; + frappe.ui.form.get_event_handler_list = function(doctype, fieldname) { if(!frappe.ui.form.handlers[doctype]) { frappe.ui.form.handlers[doctype] = {}; From 925f1273d535e0916e098c8cb41766289bb04a06 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 21 May 2021 17:11:14 +0530 Subject: [PATCH 11/15] fix: Use email_account_doc to get track_email_status value --- frappe/email/doctype/email_account/test_records.json | 3 ++- frappe/email/doctype/email_queue/email_queue.py | 2 +- frappe/tests/test_email.py | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/frappe/email/doctype/email_account/test_records.json b/frappe/email/doctype/email_account/test_records.json index fbe7d9c281..15ca2a886e 100644 --- a/frappe/email/doctype/email_account/test_records.json +++ b/frappe/email/doctype/email_account/test_records.json @@ -19,7 +19,8 @@ "unreplied_for_mins": 20, "send_notification_to": "test_unreplied@example.com", "pop3_server": "pop.test.example.com", - "no_remaining":"0" + "no_remaining":"0", + "track_email_status": 1 }, { "doctype": "ToDo", diff --git a/frappe/email/doctype/email_queue/email_queue.py b/frappe/email/doctype/email_queue/email_queue.py index 076dfc5417..4286b69bfa 100644 --- a/frappe/email/doctype/email_queue/email_queue.py +++ b/frappe/email/doctype/email_queue/email_queue.py @@ -218,7 +218,7 @@ class SendMailContext: '' message = '' - if frappe.conf.use_ssl and self.queue_doc.track_email_status: + if frappe.conf.use_ssl and self.email_account_doc.track_email_status: message = quopri.encodestring( tracker_url_html.format(frappe.local.site, self.queue_doc.communication).encode() ).decode() diff --git a/frappe/tests/test_email.py b/frappe/tests/test_email.py index af90ee7a6b..1f17764a18 100644 --- a/frappe/tests/test_email.py +++ b/frappe/tests/test_email.py @@ -15,6 +15,7 @@ class TestEmail(unittest.TestCase): frappe.db.sql("""delete from `tabEmail Queue Recipient`""") def test_email_queue(self, send_after=None): + frappe.conf.use_ssl = True frappe.sendmail(recipients=['test@example.com', 'test1@example.com'], sender="admin@example.com", reference_doctype='User', reference_name='Administrator', @@ -29,6 +30,9 @@ class TestEmail(unittest.TestCase): self.assertTrue('test1@example.com' in queue_recipients) self.assertEqual(len(queue_recipients), 2) self.assertTrue('' in email_queue[0]['message']) + # check for email tracker + self.assertTrue('frappe.core.doctype.communication.email.mark_email_as_seen' in email_queue[0]['message']) + frappe.conf.use_ssl = False def test_send_after(self): self.test_email_queue(send_after=1) From b38a15aad7ed22b99ede31b466a0416b777b0a79 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 21 May 2021 17:35:02 +0530 Subject: [PATCH 12/15] fix: Check --- frappe/public/js/frappe/form/script_manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/form/script_manager.js b/frappe/public/js/frappe/form/script_manager.js index 7e65df65ed..1fe1f1548e 100644 --- a/frappe/public/js/frappe/form/script_manager.js +++ b/frappe/public/js/frappe/form/script_manager.js @@ -5,7 +5,7 @@ frappe.provide("frappe.ui.form.handlers"); window.extend_cscript = (cscript, controller_object) => { $.extend(cscript, controller_object); - if (controller_object.__proto__) { + if (cscript && controller_object) { cscript.__proto__ = controller_object.__proto__; } }; From 114bdb57213f53d5c4ff7e5b0f232528e1237fe8 Mon Sep 17 00:00:00 2001 From: Anand Chitipothu Date: Sat, 22 May 2021 11:00:04 +0530 Subject: [PATCH 13/15] fix: issue with sending emails The sendmail functionality got broken in recent refactoring to the email module. The call to sendmail was passing from_addr and to_addrs in the wrong order. This has been fixed. Issue #13292 --- frappe/email/doctype/email_queue/email_queue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/email/doctype/email_queue/email_queue.py b/frappe/email/doctype/email_queue/email_queue.py index 076dfc5417..9ed8c2c714 100644 --- a/frappe/email/doctype/email_queue/email_queue.py +++ b/frappe/email/doctype/email_queue/email_queue.py @@ -102,7 +102,7 @@ class EmailQueue(Document): message = ctx.build_message(recipient.recipient) if not frappe.flags.in_test: - ctx.smtp_session.sendmail(recipient.recipient, self.sender, message) + ctx.smtp_session.sendmail(from_addr=self.sender, to_addrs=recipient.recipient, msg=message) ctx.add_to_sent_list(recipient) if frappe.flags.in_test: From 52a0a905a7b63d460a5f8a8aaf18034c61b1b0ed Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sat, 22 May 2021 20:44:48 +0530 Subject: [PATCH 14/15] test: Fix email tracker test case --- frappe/tests/test_email.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frappe/tests/test_email.py b/frappe/tests/test_email.py index 1f17764a18..8340db4852 100644 --- a/frappe/tests/test_email.py +++ b/frappe/tests/test_email.py @@ -15,7 +15,6 @@ class TestEmail(unittest.TestCase): frappe.db.sql("""delete from `tabEmail Queue Recipient`""") def test_email_queue(self, send_after=None): - frappe.conf.use_ssl = True frappe.sendmail(recipients=['test@example.com', 'test1@example.com'], sender="admin@example.com", reference_doctype='User', reference_name='Administrator', @@ -30,9 +29,6 @@ class TestEmail(unittest.TestCase): self.assertTrue('test1@example.com' in queue_recipients) self.assertEqual(len(queue_recipients), 2) self.assertTrue('' in email_queue[0]['message']) - # check for email tracker - self.assertTrue('frappe.core.doctype.communication.email.mark_email_as_seen' in email_queue[0]['message']) - frappe.conf.use_ssl = False def test_send_after(self): self.test_email_queue(send_after=1) @@ -75,6 +71,7 @@ class TestEmail(unittest.TestCase): self.assertTrue('CC: test1@example.com' in message) def test_cc_footer(self): + frappe.conf.use_ssl = True # test if sending with cc's makes it into header frappe.sendmail(recipients=['test@example.com'], cc=['test1@example.com'], @@ -92,7 +89,12 @@ class TestEmail(unittest.TestCase): self.assertTrue('This email was sent to test@example.com and copied to test1@example.com' in frappe.safe_decode( frappe.flags.sent_mail)) + # check for email tracker + self.assertTrue('mark_email_as_seen' in frappe.safe_decode(frappe.flags.sent_mail)) + frappe.conf.use_ssl = False + def test_expose(self): + from frappe.utils.verified_command import verify_request frappe.sendmail(recipients=['test@example.com'], cc=['test1@example.com'], From 44108135029ac064c3c409e67d40ba5da3f251cd Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 24 May 2021 09:05:00 +0530 Subject: [PATCH 15/15] fix: Use extend_cscript in make to properly extend functions of class --- .eslintrc | 3 ++- frappe/public/js/frappe/form/script_manager.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.eslintrc b/.eslintrc index a80d2910fa..cc7f555669 100644 --- a/.eslintrc +++ b/.eslintrc @@ -149,6 +149,7 @@ "before": true, "beforeEach": true, "qz": true, - "localforage": true + "localforage": true, + "extend_cscript": true } } diff --git a/frappe/public/js/frappe/form/script_manager.js b/frappe/public/js/frappe/form/script_manager.js index 1fe1f1548e..f960f4f767 100644 --- a/frappe/public/js/frappe/form/script_manager.js +++ b/frappe/public/js/frappe/form/script_manager.js @@ -8,6 +8,7 @@ window.extend_cscript = (cscript, controller_object) => { if (cscript && controller_object) { cscript.__proto__ = controller_object.__proto__; } + return cscript; }; frappe.ui.form.get_event_handler_list = function(doctype, fieldname) { @@ -81,7 +82,7 @@ frappe.ui.form.ScriptManager = class ScriptManager { $.extend(this, opts); } make(ControllerClass) { - this.frm.cscript = $.extend(this.frm.cscript, + this.frm.cscript = extend_cscript(this.frm.cscript, new ControllerClass({frm: this.frm})); } trigger(event_name, doctype, name) {