From 916612d5267f631f40c6a7703a000644b57e85eb Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 18 Feb 2019 10:18:55 +0530 Subject: [PATCH 1/7] Use get_doctypes_with_read instead of has_permission for multiple perm check --- frappe/contacts/address_and_contact.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frappe/contacts/address_and_contact.py b/frappe/contacts/address_and_contact.py index 2ab680c765..38d292e9b4 100644 --- a/frappe/contacts/address_and_contact.py +++ b/frappe/contacts/address_and_contact.py @@ -101,12 +101,13 @@ def get_permitted_and_not_permitted_links(doctype): not_permitted_links = [] meta = frappe.get_meta(doctype) + allowed_doctypes = frappe.permissions.get_doctypes_with_read() for df in meta.get_link_fields(): if df.options not in ("Customer", "Supplier", "Company", "Sales Partner"): continue - if frappe.has_permission(df.options): + if df.options in allowed_doctypes: permitted_links.append(df) else: not_permitted_links.append(df) @@ -145,10 +146,9 @@ def filter_dynamic_link_doctypes(doctype, txt, searchfield, start, page_len, fil _doctypes = tuple([d for d in _doctypes if re.search(txt+".*", _(d[0]), re.IGNORECASE)]) all_doctypes = [d[0] for d in doctypes + _doctypes] - valid_doctypes = [] + allowed_doctypes = frappe.permissions.get_doctypes_with_read() - for doctype in all_doctypes: - if frappe.has_permission(doctype): - valid_doctypes.append([doctype]) + valid_doctypes = sorted(set(all_doctypes).intersection(set(allowed_doctypes))) + valid_doctypes = [[doctype] for doctype in valid_doctypes] - return sorted(valid_doctypes) + return valid_doctypes From 976fc2ffeac048818a54474be5f08f531d2c2d11 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 20 Feb 2019 10:55:19 +0530 Subject: [PATCH 2/7] fix: Render Signature and Geolocation after dialog is shown Dialogs are hidden the first time they are created, some fields need to calculate the dimensions of their container which is not possible when they are hidden, we fix it by rendering them after the dialog is shown. --- frappe/public/js/frappe/form/controls/geolocation.js | 2 +- frappe/public/js/frappe/form/controls/signature.js | 9 ++++++++- frappe/public/js/frappe/form/quick_entry.js | 3 --- frappe/public/js/frappe/ui/dialog.js | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/frappe/public/js/frappe/form/controls/geolocation.js b/frappe/public/js/frappe/form/controls/geolocation.js index 7ba1b0b822..d68f6254b9 100644 --- a/frappe/public/js/frappe/form/controls/geolocation.js +++ b/frappe/public/js/frappe/form/controls/geolocation.js @@ -16,7 +16,7 @@ frappe.ui.form.ControlGeolocation = frappe.ui.form.ControlCode.extend({ if ($input_wrapper.is(':visible')) { this.make_map(); } else { - $(document).on('quick-entry-dialog-open', () => { + $(document).on('frappe.ui.Dialog:shown', () => { this.make_map(); }); } diff --git a/frappe/public/js/frappe/form/controls/signature.js b/frappe/public/js/frappe/form/controls/signature.js index 315a8ccfe8..82dcb8f341 100644 --- a/frappe/public/js/frappe/form/controls/signature.js +++ b/frappe/public/js/frappe/form/controls/signature.js @@ -7,7 +7,14 @@ frappe.ui.form.ControlSignature = frappe.ui.form.ControlData.extend({ // make jSignature field this.body = $('
').appendTo(me.wrapper); - this.make_pad(); + + if (this.body.is(':visible')) { + this.make_pad(); + } else { + $(document).on('frappe.ui.Dialog:shown', () => { + this.make_pad(); + }); + } this.img_wrapper = $(`
diff --git a/frappe/public/js/frappe/form/quick_entry.js b/frappe/public/js/frappe/form/quick_entry.js index a0cd22163e..257b6cd3ea 100644 --- a/frappe/public/js/frappe/form/quick_entry.js +++ b/frappe/public/js/frappe/form/quick_entry.js @@ -116,9 +116,6 @@ frappe.ui.form.QuickEntryForm = Class.extend({ this.dialog.onhide = () => frappe.quick_entry = null; this.dialog.show(); - this.dialog.$wrapper.on('shown.bs.modal', function() { - $(document).trigger('quick-entry-dialog-open'); - }); this.dialog.refresh_dependency(); this.set_defaults(); diff --git a/frappe/public/js/frappe/ui/dialog.js b/frappe/public/js/frappe/ui/dialog.js index cfbd765497..40bd865bef 100644 --- a/frappe/public/js/frappe/ui/dialog.js +++ b/frappe/public/js/frappe/ui/dialog.js @@ -83,7 +83,8 @@ frappe.ui.Dialog = class Dialog extends frappe.ui.FieldGroup { window.cur_dialog = me; frappe.ui.open_dialogs.push(me); me.focus_on_first_input(); - me.on_page_show && me.on_page_show(); + me.on_page_show && me.on_page_show(); + $(document).trigger('frappe.ui.Dialog:shown'); }) .on('scroll', function() { var $input = $('input:focus'); From 0e82b8dcf73d9b0ad65fb782ae2ed6a3071f5a0d Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 20 Feb 2019 11:20:25 +0530 Subject: [PATCH 3/7] fix: Indent using tabs --- frappe/public/js/frappe/ui/dialog.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/ui/dialog.js b/frappe/public/js/frappe/ui/dialog.js index 40bd865bef..b7b050c459 100644 --- a/frappe/public/js/frappe/ui/dialog.js +++ b/frappe/public/js/frappe/ui/dialog.js @@ -83,8 +83,8 @@ frappe.ui.Dialog = class Dialog extends frappe.ui.FieldGroup { window.cur_dialog = me; frappe.ui.open_dialogs.push(me); me.focus_on_first_input(); - me.on_page_show && me.on_page_show(); - $(document).trigger('frappe.ui.Dialog:shown'); + me.on_page_show && me.on_page_show(); + $(document).trigger('frappe.ui.Dialog:shown'); }) .on('scroll', function() { var $input = $('input:focus'); From 39a0372f4ff73276ca36277fbf990742b82c0ec7 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Wed, 20 Feb 2019 14:30:14 +0530 Subject: [PATCH 4/7] fix: Filter out null values form field array --- frappe/public/js/frappe/list/base_list.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/list/base_list.js b/frappe/public/js/frappe/list/base_list.js index aea4aeb90c..00d8d1686f 100644 --- a/frappe/public/js/frappe/list/base_list.js +++ b/frappe/public/js/frappe/list/base_list.js @@ -104,7 +104,9 @@ frappe.views.BaseList = class BaseList { } return f; }); - //de-dup + // remove null or undefined values + this.fields = this.fields.filter(Boolean); + //de-duplicate this.fields = this.fields.uniqBy(f => f[0] + f[1]); } From 013bee1c07c1f93dd743e9fe7ca219835c34aea7 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 20 Feb 2019 16:56:00 +0530 Subject: [PATCH 5/7] fix: reports are not working --- frappe/public/js/frappe/form/controls/multiselect.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/form/controls/multiselect.js b/frappe/public/js/frappe/form/controls/multiselect.js index fc5cb05010..bc4f09468b 100644 --- a/frappe/public/js/frappe/form/controls/multiselect.js +++ b/frappe/public/js/frappe/form/controls/multiselect.js @@ -35,7 +35,7 @@ frappe.ui.form.ControlMultiSelect = frappe.ui.form.ControlAutocomplete.extend({ get_value() { let data = this._super(); // find value of label from option list and return actual value string - if (this.df.options[0].label) { + if (this.df.options && this.df.options[0].label) { data = data.split(',').map(op => op.trim()); data = data.map(val => { let option = this.df.options.find(op => op.label === val); @@ -48,7 +48,7 @@ frappe.ui.form.ControlMultiSelect = frappe.ui.form.ControlAutocomplete.extend({ set_formatted_input(value) { if (!value) return; // find label of value from option list and set from it as input - if (this.df.options[0].label) { + if (this.df.options && this.df.options[0].label) { value = value.split(',').map(d => d.trim()).map(val => { let option = this.df.options.find(op => op.value === val); return option ? option.label : val; From 82036241e2458ee1e3de8ee60251cb03237fbb81 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 20 Feb 2019 17:36:07 +0530 Subject: [PATCH 6/7] fix: Dont set doctype if it is not set (#6966) --- frappe/custom/doctype/customize_form/customize_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/custom/doctype/customize_form/customize_form.js b/frappe/custom/doctype/customize_form/customize_form.js index 125db507ea..0a6f6d4d54 100644 --- a/frappe/custom/doctype/customize_form/customize_form.js +++ b/frappe/custom/doctype/customize_form/customize_form.js @@ -119,7 +119,7 @@ frappe.ui.form.on("Customize Form", { frm.set_df_property("sort_field", "options", fields); } - if(frappe.route_options) { + if(frappe.route_options && frappe.route_options.doc_type) { setTimeout(function() { frm.set_value("doc_type", frappe.route_options.doc_type); frappe.route_options = null; From 6ea90fba915ee54f3ece5a1b9c338af1bd8c7e6c Mon Sep 17 00:00:00 2001 From: Saurabh Date: Wed, 20 Feb 2019 18:42:47 +0600 Subject: [PATCH 7/7] bumped to version 11.1.8 --- frappe/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index d9cb285387..3dc745e760 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -24,7 +24,7 @@ if sys.version[0] == '2': reload(sys) sys.setdefaultencoding("utf-8") -__version__ = '11.1.7' +__version__ = '11.1.8' __title__ = "Frappe Framework" local = Local()