From 9f0721c0df44199f573ab315fe1963f028c63fac Mon Sep 17 00:00:00 2001 From: Himanshu Warekar Date: Mon, 22 Jul 2019 15:12:22 +0530 Subject: [PATCH 01/25] fix: do not check result items --- frappe/public/js/frappe/form/multi_select_dialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/form/multi_select_dialog.js b/frappe/public/js/frappe/form/multi_select_dialog.js index 0d8d2caca1..9b9ebae98f 100644 --- a/frappe/public/js/frappe/form/multi_select_dialog.js +++ b/frappe/public/js/frappe/form/multi_select_dialog.js @@ -201,7 +201,7 @@ frappe.ui.form.MultiSelectDialog = Class.extend({ let $row = $(`
- +
${contents}
`); From 117a745d909090902d49221819cc2d180c9e36ae Mon Sep 17 00:00:00 2001 From: Himanshu Warekar Date: Mon, 22 Jul 2019 15:15:29 +0530 Subject: [PATCH 02/25] fix: remove auto check of multiselect values --- frappe/public/js/frappe/form/multi_select_dialog.js | 1 - 1 file changed, 1 deletion(-) diff --git a/frappe/public/js/frappe/form/multi_select_dialog.js b/frappe/public/js/frappe/form/multi_select_dialog.js index 9b9ebae98f..739062fa61 100644 --- a/frappe/public/js/frappe/form/multi_select_dialog.js +++ b/frappe/public/js/frappe/form/multi_select_dialog.js @@ -291,7 +291,6 @@ frappe.ui.form.MultiSelectDialog = Class.extend({ if(me.date_field in result) { result["Date"] = result[me.date_field] } - result.checked = 0; result.parsed_date = Date.parse(result["Date"]); results.push(result); }); From a34519d02eadb58405242b7682e46623af2c9958 Mon Sep 17 00:00:00 2001 From: Himanshu Warekar Date: Mon, 22 Jul 2019 15:24:39 +0530 Subject: [PATCH 03/25] fix: multiselect --- frappe/public/js/frappe/form/multi_select_dialog.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frappe/public/js/frappe/form/multi_select_dialog.js b/frappe/public/js/frappe/form/multi_select_dialog.js index 739062fa61..5458e21406 100644 --- a/frappe/public/js/frappe/form/multi_select_dialog.js +++ b/frappe/public/js/frappe/form/multi_select_dialog.js @@ -201,7 +201,7 @@ frappe.ui.form.MultiSelectDialog = Class.extend({ let $row = $(`
- +
${contents}
`); @@ -291,6 +291,7 @@ frappe.ui.form.MultiSelectDialog = Class.extend({ if(me.date_field in result) { result["Date"] = result[me.date_field] } + result.checked = 0; result.parsed_date = Date.parse(result["Date"]); results.push(result); }); @@ -303,9 +304,9 @@ frappe.ui.form.MultiSelectDialog = Class.extend({ }); // Preselect oldest entry - if (me.start < 1) { - results[0].checked = 1; - } + // if (me.start < 1) { + // results[0].checked = 1; + // } } me.render_result_list(results, more); } From 804903182ac9233bbbfc6d1c117584365d694e51 Mon Sep 17 00:00:00 2001 From: Himanshu Warekar Date: Mon, 22 Jul 2019 16:13:04 +0530 Subject: [PATCH 04/25] fix: auto check only if one value --- frappe/public/js/frappe/form/multi_select_dialog.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frappe/public/js/frappe/form/multi_select_dialog.js b/frappe/public/js/frappe/form/multi_select_dialog.js index 5458e21406..d2caa24e43 100644 --- a/frappe/public/js/frappe/form/multi_select_dialog.js +++ b/frappe/public/js/frappe/form/multi_select_dialog.js @@ -304,9 +304,9 @@ frappe.ui.form.MultiSelectDialog = Class.extend({ }); // Preselect oldest entry - // if (me.start < 1) { - // results[0].checked = 1; - // } + if (me.start < 1 && r.values.length === 1) { + results[0].checked = 1; + } } me.render_result_list(results, more); } From 0405c1a23ba651c821a65c6677474802ca9c5f22 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 24 Jul 2019 16:23:28 +0530 Subject: [PATCH 05/25] fix: url fixes for changelog --- frappe/change_log/v12/v12_0_0.md | 44 ++++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/frappe/change_log/v12/v12_0_0.md b/frappe/change_log/v12/v12_0_0.md index 897b351122..0e7db3d0f6 100644 --- a/frappe/change_log/v12/v12_0_0.md +++ b/frappe/change_log/v12/v12_0_0.md @@ -1,29 +1,29 @@ # Version 12 Release Notes ### UI/UX Enhancements -1. [New Desktop](/docs/user/manual/en/using-erpnext/desktop) -1. [Keyboard Navigation](/docs/user/manual/en/using-erpnext/articles/keyboard-shortcuts) -1. [Link Preview](/version-12/release-notes/features#link-preview) -1. [New Upload Dialog](/version-12/release-notes/features#new-upload-dialog) -1. [Frequently visited links appear in Awesomebar results](/version-12/release-notes/features#frequently-visited-links-appear-in-awesomebar-results) -1. [Full Width Container]((/version-12/release-notes/features#full-width-container)) -1. [List View Enhancements](/version-12/release-notes/features#list-view-enhancements) +1. [New Desktop](https://github.com/docs/user/manual/en/using-erpnext/desktop) +1. [Keyboard Navigation](https://github.com/docs/user/manual/en/using-erpnext/articles/keyboard-shortcuts) +1. [Link Preview](https://github.com/version-12/release-notes/features#link-preview) +1. [New Upload Dialog](https://github.com/version-12/release-notes/features#new-upload-dialog) +1. [Frequently visited links appear in Awesomebar results](https://github.com/version-12/release-notes/features#frequently-visited-links-appear-in-awesomebar-results) +1. [Full Width Container]((https://github.com/version-12/release-notes/features#full-width-container)) +1. [List View Enhancements](https://github.com/version-12/release-notes/features#list-view-enhancements) ### New Automation Module -1. [Assignment Rule](/docs/user/manual/en/setting-up/automation/assignment-rule) -1. [Milestones](/docs/user/manual/en/setting-up/automation/milestone-tracker) -1. [Auto Repeat](/docs/user/manual/en/setting-up/automation/auto-repeat) +1. [Assignment Rule](https://github.com/docs/user/manual/en/setting-up/automation/assignment-rule) +1. [Milestones](https://github.com/docs/user/manual/en/setting-up/automation/milestone-tracker) +1. [Auto Repeat](https://github.com/docs/user/manual/en/setting-up/automation/auto-repeat) ### Other Changes & Enhancements -1. [Document Follow](/docs/user/manual/en/setting-up/email/document-follow) -1. [Energy Points](/docs/user/manual/en/setting-up/energy-point-system) -1. [Dashboards](/docs/user/manual/en/customize-erpnext/dashboard) -1. [Disable customization for single doctypes](/version-12/release-notes/features#disable-customization-for-single-doctypes) -1. [Email Linking](/docs/user/manual/en/setting-up/email/linking-emails-to-document) -1. [Google Contacts](/docs/user/manual/en/erpnext_integration/google_contacts) -1. [PDF Encryption](/version-12/release-notes/features#pdf-encryption) -1. [Raw Printing](/docs/user/manual/en/setting-up/print/raw-printing) -1. [Web Form Refactor](/version-12/release-notes/features#web-form-refactor) -1. [Website Refactor](/docs/user/manual/en/website) -1. [Added Track Views field to Customize Form](/version-12/release-notes/features#added-track-views-field-to-customize-form) -1. [Add custom columns to any report](/version-12/release-notes/features#add-custom-columns-to-any-report) +1. [Document Follow](https://github.com/docs/user/manual/en/setting-up/email/document-follow) +1. [Energy Points](https://github.com/docs/user/manual/en/setting-up/energy-point-system) +1. [Dashboards](https://github.com/docs/user/manual/en/customize-erpnext/dashboard) +1. [Disable customization for single doctypes](https://github.com/version-12/release-notes/features#disable-customization-for-single-doctypes) +1. [Email Linking](https://github.com/docs/user/manual/en/setting-up/email/linking-emails-to-document) +1. [Google Contacts](https://github.com/docs/user/manual/en/erpnext_integration/google_contacts) +1. [PDF Encryption](https://github.com/version-12/release-notes/features#pdf-encryption) +1. [Raw Printing](https://github.com/docs/user/manual/en/setting-up/print/raw-printing) +1. [Web Form Refactor](https://github.com/version-12/release-notes/features#web-form-refactor) +1. [Website Refactor](https://github.com/docs/user/manual/en/website) +1. [Added Track Views field to Customize Form](https://github.com/version-12/release-notes/features#added-track-views-field-to-customize-form) +1. [Add custom columns to any report](https://github.com/version-12/release-notes/features#add-custom-columns-to-any-report) From ae472819250bfca770d0df4bc1d460fee3b15b3e Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Thu, 25 Jul 2019 11:52:32 +0530 Subject: [PATCH 06/25] fix: added filter for doctype in Session Default Settings --- .../session_default_settings.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 frappe/core/doctype/session_default_settings/session_default_settings.js diff --git a/frappe/core/doctype/session_default_settings/session_default_settings.js b/frappe/core/doctype/session_default_settings/session_default_settings.js new file mode 100644 index 0000000000..e3e50704db --- /dev/null +++ b/frappe/core/doctype/session_default_settings/session_default_settings.js @@ -0,0 +1,15 @@ +// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +// MIT License. See license.txt + +frappe.ui.form.on('Session Default Settings', { + refresh: function(frm) { + frm.set_query('ref_doctype', 'session_defaults', function() { + return { + filters: { + issingle: 0, + istable: 0 + } + }; + }); + } +}); From b5546e2cb7c1f25933ee96c7de4e93bcc571894d Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Thu, 25 Jul 2019 13:14:06 +0530 Subject: [PATCH 07/25] fix: session default not set in listview filter --- frappe/public/js/frappe/list/base_list.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frappe/public/js/frappe/list/base_list.js b/frappe/public/js/frappe/list/base_list.js index 9141bcc525..e4b42fcbf1 100644 --- a/frappe/public/js/frappe/list/base_list.js +++ b/frappe/public/js/frappe/list/base_list.js @@ -617,12 +617,14 @@ class FilterArea { options = options.join("\n"); } } + let default_value = fieldtype === 'Link' ? frappe.defaults.get_user_default(options) : null return { fieldtype: fieldtype, label: __(df.label), options: options, fieldname: df.fieldname, condition: condition, + default: default_value, onchange: () => this.refresh_list_view(), ignore_link_validation: fieldtype === 'Dynamic Link' }; From af3341ab1b4d9f87cd38401cc04543b9ddc1a740 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Thu, 25 Jul 2019 14:01:57 +0530 Subject: [PATCH 08/25] fix: clear session defaults if prompt field is cleared --- frappe/public/js/frappe/ui/toolbar/toolbar.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/ui/toolbar/toolbar.js b/frappe/public/js/frappe/ui/toolbar/toolbar.js index ed5091b52f..c72dac49f8 100644 --- a/frappe/public/js/frappe/ui/toolbar/toolbar.js +++ b/frappe/public/js/frappe/ui/toolbar/toolbar.js @@ -255,6 +255,12 @@ frappe.ui.toolbar.setup_session_defaults = function() { }; } frappe.prompt(fields, function(values) { + //if default is not set for a particular field in prompt + fields.forEach(function(d) { + if (!values[d.fieldname]) { + values[d.fieldname] = ""; + } + }); frappe.call({ method: 'frappe.core.doctype.session_default_settings.session_default_settings.set_session_default_values', args: { @@ -266,7 +272,6 @@ frappe.ui.toolbar.setup_session_defaults = function() { 'message': __('Session Defaults Saved'), 'indicator': 'green' }); - frappe.clear_cache(); } else { frappe.show_alert({ 'message': __('An error occurred while setting Session Defaults'), From 5797f54e4c9546e2074b03f619213907615fdea8 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Thu, 25 Jul 2019 14:34:34 +0530 Subject: [PATCH 09/25] fix: reload to reflect the session defaults --- frappe/public/js/frappe/ui/toolbar/toolbar.js | 1 + 1 file changed, 1 insertion(+) diff --git a/frappe/public/js/frappe/ui/toolbar/toolbar.js b/frappe/public/js/frappe/ui/toolbar/toolbar.js index c72dac49f8..e392de44b1 100644 --- a/frappe/public/js/frappe/ui/toolbar/toolbar.js +++ b/frappe/public/js/frappe/ui/toolbar/toolbar.js @@ -272,6 +272,7 @@ frappe.ui.toolbar.setup_session_defaults = function() { 'message': __('Session Defaults Saved'), 'indicator': 'green' }); + frappe.ui.toolbar.clear_cache(); } else { frappe.show_alert({ 'message': __('An error occurred while setting Session Defaults'), From 8e0c9d474ccf009d4df8241d9241224bff8f2f62 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Thu, 25 Jul 2019 14:51:47 +0530 Subject: [PATCH 10/25] fix: codacy fixes --- .../session_default_settings.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frappe/core/doctype/session_default_settings/session_default_settings.js b/frappe/core/doctype/session_default_settings/session_default_settings.js index e3e50704db..f7cce14809 100644 --- a/frappe/core/doctype/session_default_settings/session_default_settings.js +++ b/frappe/core/doctype/session_default_settings/session_default_settings.js @@ -3,13 +3,13 @@ frappe.ui.form.on('Session Default Settings', { refresh: function(frm) { - frm.set_query('ref_doctype', 'session_defaults', function() { - return { - filters: { - issingle: 0, - istable: 0 - } - }; - }); + frm.set_query('ref_doctype', 'session_defaults', function() { + return { + filters: { + issingle: 0, + istable: 0 + } + }; + }); } }); From 5a98598850e63b2290bd5535fbf4e2f002550969 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Thu, 25 Jul 2019 14:58:12 +0530 Subject: [PATCH 11/25] fix: codacy fixes --- frappe/public/js/frappe/list/base_list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/list/base_list.js b/frappe/public/js/frappe/list/base_list.js index e4b42fcbf1..b81d7695bd 100644 --- a/frappe/public/js/frappe/list/base_list.js +++ b/frappe/public/js/frappe/list/base_list.js @@ -617,7 +617,7 @@ class FilterArea { options = options.join("\n"); } } - let default_value = fieldtype === 'Link' ? frappe.defaults.get_user_default(options) : null + let default_value = fieldtype === 'Link' ? frappe.defaults.get_user_default(options) : null; return { fieldtype: fieldtype, label: __(df.label), From 0d2043d76bbfa97f69c5a35467d645a1c0f74657 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Thu, 25 Jul 2019 17:03:35 +0530 Subject: [PATCH 12/25] refactor: translated table headings --- frappe/public/js/frappe/web_form/web_form_list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/web_form/web_form_list.js b/frappe/public/js/frappe/web_form/web_form_list.js index 709ee66e06..c92b62f013 100644 --- a/frappe/public/js/frappe/web_form/web_form_list.js +++ b/frappe/public/js/frappe/web_form/web_form_list.js @@ -154,7 +154,7 @@ export default class WebFormList { add_heading(row, "Sr."); this.columns.forEach(col => { let th = document.createElement("th"); - let text = document.createTextNode(col.label); + let text = document.createTextNode(__(col.label)); th.appendChild(text); row.appendChild(th); }); From 8d1350135eb807673b5f61361ca3423ab415c407 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Thu, 25 Jul 2019 23:10:43 +0530 Subject: [PATCH 13/25] fix: tests --- frappe/public/js/frappe/list/base_list.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/list/base_list.js b/frappe/public/js/frappe/list/base_list.js index b81d7695bd..79555b7e48 100644 --- a/frappe/public/js/frappe/list/base_list.js +++ b/frappe/public/js/frappe/list/base_list.js @@ -598,7 +598,7 @@ class FilterArea { } const doctype_fields = this.list_view.meta.fields; - + let session_defaults = frappe.db.get_single_value('Session Default Settings', 'session_defaults'); fields = fields.concat(doctype_fields.filter( df => df.in_standard_filter && frappe.model.is_value_type(df.fieldtype) @@ -617,7 +617,7 @@ class FilterArea { options = options.join("\n"); } } - let default_value = fieldtype === 'Link' ? frappe.defaults.get_user_default(options) : null; + let default_value = ((fieldtype === 'Link') && (session_defaults.ref_doctype === options)) ? frappe.defaults.get_user_default(options) : null; return { fieldtype: fieldtype, label: __(df.label), From d2e6d12632a012b75dc38f9bb16944be66e84d4c Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Fri, 26 Jul 2019 01:38:29 +0530 Subject: [PATCH 14/25] fix: list view filter not showing defaults --- frappe/public/js/frappe/list/base_list.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/list/base_list.js b/frappe/public/js/frappe/list/base_list.js index 79555b7e48..362378c21e 100644 --- a/frappe/public/js/frappe/list/base_list.js +++ b/frappe/public/js/frappe/list/base_list.js @@ -598,7 +598,6 @@ class FilterArea { } const doctype_fields = this.list_view.meta.fields; - let session_defaults = frappe.db.get_single_value('Session Default Settings', 'session_defaults'); fields = fields.concat(doctype_fields.filter( df => df.in_standard_filter && frappe.model.is_value_type(df.fieldtype) @@ -617,7 +616,10 @@ class FilterArea { options = options.join("\n"); } } - let default_value = ((fieldtype === 'Link') && (session_defaults.ref_doctype === options)) ? frappe.defaults.get_user_default(options) : null; + let default_value = (fieldtype === 'Link') ? frappe.defaults.get_user_default(options) : null; + if (['__default', '__global'].includes(default_value)) { + default_value = null; + } return { fieldtype: fieldtype, label: __(df.label), From 570239cd48b32bb6e0042e6f3471200ae05df6d2 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 26 Jul 2019 10:51:06 +0530 Subject: [PATCH 15/25] fix: Patch to create file in right location --- frappe/core/doctype/file/file.py | 15 +++++---- .../patches/v12_0/fix_public_private_files.py | 33 +++++++++++++++++++ 2 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 frappe/patches/v12_0/fix_public_private_files.py diff --git a/frappe/core/doctype/file/file.py b/frappe/core/doctype/file/file.py index 6e6cce52bf..8fac317100 100755 --- a/frappe/core/doctype/file/file.py +++ b/frappe/core/doctype/file/file.py @@ -473,7 +473,7 @@ class File(NestedSet): return None - def save_file(self, content=None, decode=False): + def save_file(self, content=None, decode=False, ignore_existing_file_check=False): file_exists = False self.content = content if decode: @@ -490,12 +490,15 @@ class File(NestedSet): self.content_hash = get_content_hash(self.content) self.content_type = mimetypes.guess_type(self.file_name)[0] + _file = False + # check if a file exists with the same content hash and is also in the same folder (public or private) - _file = frappe.get_value("File", { - "content_hash": self.content_hash, - "is_private": self.is_private - }, - ["file_url"]) + if not ignore_existing_file_check: + _file = frappe.get_value("File", { + "content_hash": self.content_hash, + "is_private": self.is_private + }, + ["file_url"]) if _file: self.file_url = _file diff --git a/frappe/patches/v12_0/fix_public_private_files.py b/frappe/patches/v12_0/fix_public_private_files.py new file mode 100644 index 0000000000..001f9a2d2e --- /dev/null +++ b/frappe/patches/v12_0/fix_public_private_files.py @@ -0,0 +1,33 @@ +import frappe +import os + +def execute(): + files = frappe.get_all('File', + fields=['is_private', 'file_url', 'name'], + filters={'is_folder': 0}) + + for file in files: + file_url = file.file_url + if file.is_private: + if not file_url.startswith('/private/files/'): + generate_file(file.name) + else: + if file_url.startswith('/private/files/'): + generate_file(file.name) + +def generate_file(file_name): + try: + file_doc = frappe.get_doc('File', file_name) + # private + new_doc = frappe.new_doc('File') + new_doc.is_private = file_doc.is_private + new_doc.file_name = file_doc.file_name + # to create copy of file in right location + # if the file doc is private file will be created in /private folder + # if the file doc is public file will be created in /files folder + new_doc.save_file(content=file_doc.get_content(), ignore_existing_file_check=True) + + file_doc.file_url = new_doc.file_url + file_doc.save() + except IOError: + pass \ No newline at end of file From 2020f797714b24f317223b53008cf33f252be63c Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 26 Jul 2019 11:11:23 +0530 Subject: [PATCH 16/25] fix: Typo --- frappe/patches/v12_0/fix_public_private_files.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frappe/patches/v12_0/fix_public_private_files.py b/frappe/patches/v12_0/fix_public_private_files.py index 001f9a2d2e..3f8f30379e 100644 --- a/frappe/patches/v12_0/fix_public_private_files.py +++ b/frappe/patches/v12_0/fix_public_private_files.py @@ -23,8 +23,8 @@ def generate_file(file_name): new_doc.is_private = file_doc.is_private new_doc.file_name = file_doc.file_name # to create copy of file in right location - # if the file doc is private file will be created in /private folder - # if the file doc is public file will be created in /files folder + # if the file doc is private then the file will be created in /private folder + # if the file doc is public then the file will be created in /files folder new_doc.save_file(content=file_doc.get_content(), ignore_existing_file_check=True) file_doc.file_url = new_doc.file_url From 65884a0a3ed4d5cedf248109579ab25ab8f5ae7a Mon Sep 17 00:00:00 2001 From: Sahil Khan Date: Fri, 26 Jul 2019 13:06:32 +0550 Subject: [PATCH 17/25] bumped to version 12.0.1 --- frappe/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index 62576bea8e..c2008a059d 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -23,7 +23,7 @@ if sys.version[0] == '2': reload(sys) sys.setdefaultencoding("utf-8") -__version__ = '12.0.0' +__version__ = '12.0.1' __title__ = "Frappe Framework" local = Local() From 02e2d17d71b613b62b1a9c44faf8cbde326833b5 Mon Sep 17 00:00:00 2001 From: Anurag Mishra <32095923+Anurag810@users.noreply.github.com> Date: Fri, 26 Jul 2019 14:57:46 +0530 Subject: [PATCH 18/25] fix(dashboards): Map Chart Type Average to aggregate function AVG (#8006) Co-authored-by: adityahase --- frappe/desk/doctype/dashboard_chart/dashboard_chart.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frappe/desk/doctype/dashboard_chart/dashboard_chart.py b/frappe/desk/doctype/dashboard_chart/dashboard_chart.py index 53d1110e83..73677b1a95 100644 --- a/frappe/desk/doctype/dashboard_chart/dashboard_chart.py +++ b/frappe/desk/doctype/dashboard_chart/dashboard_chart.py @@ -45,7 +45,7 @@ def get(chart_name, from_date=None, to_date=None, refresh = None): '''.format( unit_function = get_unit_function(chart.based_on, timegrain), datefield = chart.based_on, - aggregate_function = chart.chart_type, + aggregate_function = get_aggregate_function(chart.chart_type), value_field = chart.value_based_on or '1', doctype = chart.document_type, conditions = conditions, @@ -67,6 +67,13 @@ def get(chart_name, from_date=None, to_date=None, refresh = None): }] } +def get_aggregate_function(chart_type): + return { + "Sum": "SUM", + "Count": "COUNT", + "Average": "AVG" + }[chart_type] + def convert_to_dates(data, timegrain): result = [] for d in data: From 72427d0b2577095c01a5eeeecc706aa5b085efc0 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Fri, 26 Jul 2019 12:31:42 +0530 Subject: [PATCH 19/25] fix: Unknown string format:', u'Total' --- frappe/templates/emails/auto_email_report.html | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/frappe/templates/emails/auto_email_report.html b/frappe/templates/emails/auto_email_report.html index 50ab5b1fe3..a658c988a9 100644 --- a/frappe/templates/emails/auto_email_report.html +++ b/frappe/templates/emails/auto_email_report.html @@ -33,9 +33,15 @@ {% for row in data %} {% for col in columns %} - - {{- frappe.format(row[col.fieldname], col, row) -}} - + {% if row[col.fieldname] == 'Total' %} + + {{- row[col.fieldname] -}} + + {% else %} + + {{- frappe.format(row[col.fieldname], col, row) -}} + + {% endif %} {% endfor %} {% endfor %} From 03e300289a82227afad64975234f8d16d896dc2d Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Fri, 26 Jul 2019 15:14:22 +0530 Subject: [PATCH 20/25] fix: added default parameters in make_auto_repeat --- frappe/automation/doctype/auto_repeat/auto_repeat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/automation/doctype/auto_repeat/auto_repeat.py b/frappe/automation/doctype/auto_repeat/auto_repeat.py index 8a429b93f9..0ad0a9e9c6 100644 --- a/frappe/automation/doctype/auto_repeat/auto_repeat.py +++ b/frappe/automation/doctype/auto_repeat/auto_repeat.py @@ -325,7 +325,7 @@ def set_auto_repeat_as_completed(): doc.save() @frappe.whitelist() -def make_auto_repeat(doctype, docname, frequency, start_date, end_date = None): +def make_auto_repeat(doctype, docname, frequency = 'Daily', start_date = today(), end_date = None): doc = frappe.new_doc('Auto Repeat') doc.reference_doctype = doctype doc.reference_document = docname From 2f76e70f4043527758209bfb5d63813c9c4b2dd3 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Fri, 26 Jul 2019 15:15:37 +0530 Subject: [PATCH 21/25] fix: end date for auto repeat --- frappe/automation/doctype/auto_repeat/auto_repeat.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frappe/automation/doctype/auto_repeat/auto_repeat.py b/frappe/automation/doctype/auto_repeat/auto_repeat.py index 0ad0a9e9c6..71bf9cfeb9 100644 --- a/frappe/automation/doctype/auto_repeat/auto_repeat.py +++ b/frappe/automation/doctype/auto_repeat/auto_repeat.py @@ -61,7 +61,8 @@ class AutoRepeat(Document): frappe.throw(_("Enable Allow Auto Repeat for the doctype {0} in Customize Form").format(self.reference_doctype)) def validate_dates(self): - self.validate_from_to_dates('start_date', 'end_date') + if self.end_date: + self.validate_from_to_dates('start_date', 'end_date') if self.end_date == self.start_date: frappe.throw(_('{0} should not be same as {1}').format(frappe.bold('End Date'), frappe.bold('Start Date'))) From 8dd180ae822691f860b144511ced56da1c5d09f1 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Fri, 26 Jul 2019 16:03:33 +0530 Subject: [PATCH 22/25] fix: removed dynamic value in default parameter --- frappe/automation/doctype/auto_repeat/auto_repeat.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frappe/automation/doctype/auto_repeat/auto_repeat.py b/frappe/automation/doctype/auto_repeat/auto_repeat.py index 71bf9cfeb9..334862f27a 100644 --- a/frappe/automation/doctype/auto_repeat/auto_repeat.py +++ b/frappe/automation/doctype/auto_repeat/auto_repeat.py @@ -326,7 +326,9 @@ def set_auto_repeat_as_completed(): doc.save() @frappe.whitelist() -def make_auto_repeat(doctype, docname, frequency = 'Daily', start_date = today(), end_date = None): +def make_auto_repeat(doctype, docname, frequency = 'Daily', start_date = None, end_date = None): + if not start_date: + start_date = getdate(today()) doc = frappe.new_doc('Auto Repeat') doc.reference_doctype = doctype doc.reference_document = docname From 4c14574270469ed223758e41bf087e9044f39208 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Fri, 26 Jul 2019 18:04:53 +0530 Subject: [PATCH 23/25] fix: date comparison fix --- frappe/automation/doctype/auto_repeat/auto_repeat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/automation/doctype/auto_repeat/auto_repeat.py b/frappe/automation/doctype/auto_repeat/auto_repeat.py index 334862f27a..864a60e498 100644 --- a/frappe/automation/doctype/auto_repeat/auto_repeat.py +++ b/frappe/automation/doctype/auto_repeat/auto_repeat.py @@ -33,7 +33,7 @@ class AutoRepeat(Document): def before_insert(self): if not frappe.flags.in_test: start_date = self.start_date - today_date = today() + today_date = getdate(today()) if start_date <= today_date: start_date = today_date From ce60f98ab68e72afcf2621fc3da515de9ca22fc9 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Fri, 26 Jul 2019 20:49:46 +0530 Subject: [PATCH 24/25] Revert "fix(security): Disallow unnecessary characters in group_by and fields" This reverts commit fb8993663c2e587d78667937ad356d17610a2214. --- frappe/model/db_query.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/frappe/model/db_query.py b/frappe/model/db_query.py index 7767d2a021..53a1c6c13d 100644 --- a/frappe/model/db_query.py +++ b/frappe/model/db_query.py @@ -240,9 +240,6 @@ class DatabaseQuery(object): _is_query(field) - invalid_characters_regex = r".*[^a-zA-Z0-9-_ ,`'\"\*\.\(\)].*" - if re.match(invalid_characters_regex, field): - frappe.throw(_("Illegal characters in SQL query")) def extract_tables(self): """extract tables from fields""" @@ -691,9 +688,6 @@ class DatabaseQuery(object): if 'select' in _lower and ' from ' in _lower: frappe.throw(_('Cannot use sub-query in order by')) - invalid_characters_regex = r".*[^a-z0-9-_ ,`'\"\.\(\)].*" - if re.match(invalid_characters_regex, _lower): - frappe.throw(_("Illegal characters in SQL query")) for field in parameters.split(","): if "." in field and field.strip().startswith("`tab"): From fb896a460ee33200e21751f836afcec21fedc0c4 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Fri, 26 Jul 2019 20:49:56 +0530 Subject: [PATCH 25/25] Revert "fix(security): Make jinja rendering tighter" This reverts commit b30199b7f5c9dc62563fc4c528432f1160de0fd3. --- frappe/utils/jinja.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/utils/jinja.py b/frappe/utils/jinja.py index f8745b82c3..7a27fb3c3b 100644 --- a/frappe/utils/jinja.py +++ b/frappe/utils/jinja.py @@ -71,7 +71,7 @@ def render_template(template, context, is_path=None, safe_render=True): or (template.endswith('.html') and '\n' not in template)): return get_jenv().get_template(template).render(context) else: - if safe_render and "__" in template: + if safe_render and ".__" in template: throw("Illegal template") try: return get_jenv().from_string(template).render(context)