From 397444842e2e340f5094df7074915db0ff4e2082 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 28 Sep 2017 12:00:00 +0530 Subject: [PATCH 1/5] [fix] totals in reportview.js --- .../js/frappe/views/reports/reportview.js | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/frappe/public/js/frappe/views/reports/reportview.js b/frappe/public/js/frappe/views/reports/reportview.js index b7fd287b02..9e4b84bfaf 100644 --- a/frappe/public/js/frappe/views/reports/reportview.js +++ b/frappe/public/js/frappe/views/reports/reportview.js @@ -391,7 +391,7 @@ frappe.views.ReportView = frappe.ui.BaseList.extend({ var me = this; var data = this.get_unique_data(this.column_info); - this.set_totals_row(); + this.set_totals_row(data); // add sr in data $.each(data, function(i, v) { @@ -475,25 +475,24 @@ frappe.views.ReportView = frappe.ui.BaseList.extend({ get_unique_data: function(columns) { // if child columns are selected, show parent data only once - - var me = this; - if (this.show_all_data || !this.has_child_column()) { - return this.data; - } + let has_child_column = this.has_child_column(); var data = [], prev_row = null; - this.data.forEach(function(d) { - if(prev_row && d.name == prev_row.name) { + this.data.forEach((d) => { + if (this.show_all_data || !has_child_column) { + data.push(d); + } else if (prev_row && d.name == prev_row.name) { var new_row = {}; - columns.forEach(function(c) { - if(!c.docfield || c.docfield.parent!==me.doctype) { + columns.forEach((c) => { + if(!c.docfield || c.docfield.parent!==this.doctype) { var val = d[c.field]; // add child table row name for update - if(c.docfield && c.docfield.parent!==me.doctype) { + if(c.docfield && c.docfield.parent!==this.doctype) { new_row[c.docfield.parent+":name"] = d[c.docfield.parent+":name"]; } } else { var val = ''; + new_row.__is_repeat = true; } new_row[c.field] = val; }); @@ -613,21 +612,16 @@ frappe.views.ReportView = frappe.ui.BaseList.extend({ var me = this; this.page.add_inner_button(__('Show Totals'), function() { - me.add_totals_row = 1 - (me.add_totals_row ? me.add_totals_row : 0); + me.add_totals_row = !!!me.add_totals_row; me.render_view(); }); }, - set_totals_row: function() { - // remove existing totals row - if(this.data.length && this.data[this.data.length-1]._totals_row) { - this.data.pop(); - } - + set_totals_row: function(data) { if(this.add_totals_row) { var totals_row = {_totals_row: 1}; - if(this.data.length) { - this.data.forEach(function(row, ri) { + if(data.length) { + data.forEach(function(row, ri) { $.each(row, function(key, value) { if($.isNumeric(value)) { totals_row[key] = (totals_row[key] || 0) + value; @@ -635,7 +629,7 @@ frappe.views.ReportView = frappe.ui.BaseList.extend({ }); }); } - this.data.push(totals_row); + data.push(totals_row); } }, From 935680d16095ea38cef5b7ea6892987e38b750c1 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 28 Sep 2017 12:11:25 +0530 Subject: [PATCH 2/5] [minor] command to rebuild global search frappe/erpnext#10951 (#4205) --- frappe/commands/utils.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/frappe/commands/utils.py b/frappe/commands/utils.py index 7c18bdbc78..710327b5fe 100644 --- a/frappe/commands/utils.py +++ b/frappe/commands/utils.py @@ -4,6 +4,7 @@ import json, os, sys from distutils.spawn import find_executable import frappe from frappe.commands import pass_context, get_site +from frappe.utils import update_progress_bar @click.command('build') @click.option('--make-copy', is_flag=True, default=False, help='Copy the files instead of symlinking') @@ -484,6 +485,24 @@ def setup_help(context): finally: frappe.destroy() +@click.command('rebuild-global-search') +@pass_context +def rebuild_global_search(context): + '''Setup help table in the current site (called after migrate)''' + from frappe.utils.global_search import (get_doctypes_with_global_search, rebuild_for_doctype) + + for site in context.sites: + try: + frappe.init(site) + frappe.connect() + doctypes = get_doctypes_with_global_search() + for i, doctype in enumerate(doctypes): + rebuild_for_doctype(doctype) + update_progress_bar('Rebuilding Global Search', i, len(doctypes)) + + finally: + frappe.destroy() + commands = [ build, @@ -512,5 +531,6 @@ commands = [ _bulk_rename, add_to_email_queue, setup_global_help, - setup_help + setup_help, + rebuild_global_search ] From d0fd1482c453c01ea54af87f43a0695ef0862472 Mon Sep 17 00:00:00 2001 From: Makarand Bauskar Date: Thu, 28 Sep 2017 12:12:16 +0530 Subject: [PATCH 3/5] [hotfix] ignore the disabled reports in sidebar Reports section (#4200) --- frappe/boot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frappe/boot.py b/frappe/boot.py index 9f0c05a6ce..ef14445af5 100644 --- a/frappe/boot.py +++ b/frappe/boot.py @@ -138,8 +138,10 @@ def get_user_page_or_report(parent): and tab{parent}.name not in ( select `tabCustom Role`.{field} from `tabCustom Role` where `tabCustom Role`.{field} is not null) - """.format(parent=parent, column=column, - roles = ', '.join(['%s']*len(roles)), field=parent.lower()), roles, as_dict=True) + {condition} + """.format(parent=parent, column=column, roles = ', '.join(['%s']*len(roles)), + field=parent.lower(), condition="and tabReport.disabled=0" if parent == "Report" else ""), + roles, as_dict=True) for p in standard_roles: if p.name not in has_role: From 780df0be60bbf13bedf17ba35ae793e1e24dddc7 Mon Sep 17 00:00:00 2001 From: Makarand Bauskar Date: Thu, 28 Sep 2017 12:14:00 +0530 Subject: [PATCH 4/5] [hotfix] pull emails from all incoming email accounts instead of enqueue single email account (#4199) --- .../doctype/email_account/email_account.py | 39 ++++++++++++------- frappe/email/smtp.py | 8 +++- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/frappe/email/doctype/email_account/email_account.py b/frappe/email/doctype/email_account/email_account.py index 307e2e46ff..a36d461c60 100755 --- a/frappe/email/doctype/email_account/email_account.py +++ b/frappe/email/doctype/email_account/email_account.py @@ -685,27 +685,36 @@ def pull(now=False): frappe.cache().set_value("workers:no-internet", False) else: return + queued_jobs = get_jobs(site=frappe.local.site, key='job_name')[frappe.local.site] - for email_account in frappe.get_list("Email Account", - filters={"enable_incoming": 1, "awaiting_password": 0}): - if now: - pull_from_email_account(email_account.name) + email_accounts = frappe.db.sql_list("""select name from `tabEmail Account` where + enable_incoming=1 and awaiting_password=0""") - else: - # job_name is used to prevent duplicates in queue - job_name = 'pull_from_email_account|{0}'.format(email_account.name) + # No incoming email account available + if not email_accounts: + return - if job_name not in queued_jobs: - enqueue(pull_from_email_account, 'short', event='all', job_name=job_name, - email_account=email_account.name) + if now: + pull_from_email_accounts(email_accounts) + else: + # job_name is used to prevent duplicates in queue + job_name = 'pull_from_email_accounts|{0}'.format(",".join(email_accounts)) -def pull_from_email_account(email_account): + if job_name not in queued_jobs: + enqueue(pull_from_email_accounts, 'short', event='all', job_name=job_name, + email_accounts=email_accounts) + +def pull_from_email_accounts(email_accounts): '''Runs within a worker process''' - email_account = frappe.get_doc("Email Account", email_account) - email_account.receive() + if not email_accounts: + return + + for email_account in email_accounts: + email_account = frappe.get_doc("Email Account", email_account) + email_account.receive() - # mark Email Flag Queue mail as read - email_account.mark_emails_as_read_unread() + # mark Email Flag Queue mail as read + email_account.mark_emails_as_read_unread() def get_max_email_uid(email_account): # get maximum uid of emails diff --git a/frappe/email/smtp.py b/frappe/email/smtp.py index 1c6b2d89df..62d0dce95b 100644 --- a/frappe/email/smtp.py +++ b/frappe/email/smtp.py @@ -47,7 +47,9 @@ def get_outgoing_email_account(raise_exception_not_set=True, append_to=None, sen if not getattr(frappe.local, "outgoing_email_account", None): frappe.local.outgoing_email_account = {} - if not frappe.local.outgoing_email_account.get(append_to or sender_email_id or "default"): + if not frappe.local.outgoing_email_account.get(append_to) \ + or frappe.local.outgoing_email_account.get(sender_email_id) \ + or frappe.local.outgoing_email_account.get("default"): email_account = None if append_to: @@ -77,7 +79,9 @@ def get_outgoing_email_account(raise_exception_not_set=True, append_to=None, sen frappe.local.outgoing_email_account[append_to or sender_email_id or "default"] = email_account - return frappe.local.outgoing_email_account[append_to or sender_email_id or "default"] + return frappe.local.outgoing_email_account.get(append_to) \ + or frappe.local.outgoing_email_account.get(sender_email_id) \ + or frappe.local.outgoing_email_account.get("default") def get_default_outgoing_email_account(raise_exception_not_set=True): '''conf should be like: From 4a6277cf05cd0165c4a47259f2c42d636acd4fd0 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 28 Sep 2017 12:56:50 +0600 Subject: [PATCH 5/5] bumped to version 9.0.6 --- frappe/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index 7e63a9b69b..bb20fb2354 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__ = '9.0.5' +__version__ = '9.0.6' __title__ = "Frappe Framework" local = Local()