From d0175628ce0946348e31af748a19174a607995a8 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 6 Dec 2016 19:09:00 +0530 Subject: [PATCH 1/7] [fix] render from custom template if custom_html is set in print format --- .../doctype/print_format/print_format.js | 21 +++++++++++-------- frappe/www/print.py | 14 +++++++++---- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/frappe/print/doctype/print_format/print_format.js b/frappe/print/doctype/print_format/print_format.js index 93dd3c1569..c6bef576db 100644 --- a/frappe/print/doctype/print_format/print_format.js +++ b/frappe/print/doctype/print_format/print_format.js @@ -15,14 +15,6 @@ frappe.ui.form.on("Print Format", "refresh", function(frm) { } if(!frm.is_new()) { - frm.add_custom_button(__("Edit Format"), function() { - if(!frm.doc.doc_type) { - msgprint(__("Please select DocType first")); - return; - } - frappe.set_route("print-format-builder", frm.doc.name); - }); - frm.add_custom_button(__("Make Default"), function() { frappe.call({ method: "frappe.print.doctype.print_format.print_format.make_default", @@ -31,14 +23,25 @@ frappe.ui.form.on("Print Format", "refresh", function(frm) { } }) }); + frm.trigger('custom_format'); } }); frappe.ui.form.on("Print Format", { - 'custom_format': function(frm) { + custom_format: function(frm) { value = frm.doc.custom_format ? 0:1; frm.set_value('align_labels_left', value); frm.set_value('show_section_headings', value); frm.set_value('line_breaks', value); + + if(!frm.doc.custom_format) { + frm.add_custom_button(__("Edit Format"), function() { + if(!frm.doc.doc_type) { + msgprint(__("Please select DocType first")); + return; + } + frappe.set_route("print-format-builder", frm.doc.name); + }); + } } }) diff --git a/frappe/www/print.py b/frappe/www/print.py index d9a0121df4..a82030b26a 100644 --- a/frappe/www/print.py +++ b/frappe/www/print.py @@ -100,7 +100,14 @@ def get_html(doc, name=None, print_format=None, meta=None, doc._line_breaks = print_format.line_breaks doc._align_labels_left = print_format.align_labels_left - if print_format.format_data: + def get_template_from_string(): + return jenv.from_string(get_print_format(doc.doctype, + print_format)) + + if print_format.custom_format: + template = get_template_from_string() + + elif print_format.format_data: # set format data format_data = json.loads(print_format.format_data) for df in format_data: @@ -113,9 +120,8 @@ def get_html(doc, name=None, print_format=None, meta=None, template = "standard" - elif print_format.standard=="Yes" or print_format.custom_format: - template = jenv.from_string(get_print_format(doc.doctype, - print_format)) + elif print_format.standard=="Yes": + template = get_template_from_string() else: # fallback From e26619bf264d16c51dae5412d92d661386895a3a Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 6 Dec 2016 19:16:08 +0530 Subject: [PATCH 2/7] [minor] js fix --- .../doctype/print_format/print_format.js | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/frappe/print/doctype/print_format/print_format.js b/frappe/print/doctype/print_format/print_format.js index c6bef576db..719d5d9291 100644 --- a/frappe/print/doctype/print_format/print_format.js +++ b/frappe/print/doctype/print_format/print_format.js @@ -2,46 +2,47 @@ frappe.ui.form.on("Print Format", "onload", function(frm) { frm.add_fetch("doc_type", "module", "module"); }); -frappe.ui.form.on("Print Format", "refresh", function(frm) { - frm.set_intro(""); - frm.toggle_enable(["html", "doc_type", "module"], false); - if (user==="Administrator" || frm.doc.standard==="No") { - frm.toggle_enable(["html", "doc_type", "module"], true); - frm.enable_save(); - } - - if(frm.doc.standard==="Yes" && user !== "Administrator") { - frm.set_intro(__("Please duplicate this to make changes")); - } - - if(!frm.is_new()) { - frm.add_custom_button(__("Make Default"), function() { - frappe.call({ - method: "frappe.print.doctype.print_format.print_format.make_default", - args: { - name: frm.doc.name - } - }) - }); - frm.trigger('custom_format'); - } -}); - frappe.ui.form.on("Print Format", { + refresh: function(frm) { + frm.set_intro(""); + frm.toggle_enable(["html", "doc_type", "module"], false); + if (user==="Administrator" || frm.doc.standard==="No") { + frm.toggle_enable(["html", "doc_type", "module"], true); + frm.enable_save(); + } + + if(frm.doc.standard==="Yes" && user !== "Administrator") { + frm.set_intro(__("Please duplicate this to make changes")); + } + frm.trigger('render_buttons'); + }, + render_buttons: function(frm) { + frm.page.clear_inner_toolbar(); + if(!frm.is_new()) { + if(!frm.doc.custom_format) { + frm.add_custom_button(__("Edit Format"), function() { + if(!frm.doc.doc_type) { + msgprint(__("Please select DocType first")); + return; + } + frappe.set_route("print-format-builder", frm.doc.name); + }); + } + frm.add_custom_button(__("Make Default"), function() { + frappe.call({ + method: "frappe.print.doctype.print_format.print_format.make_default", + args: { + name: frm.doc.name + } + }) + }); + } + }, custom_format: function(frm) { value = frm.doc.custom_format ? 0:1; frm.set_value('align_labels_left', value); frm.set_value('show_section_headings', value); frm.set_value('line_breaks', value); - - if(!frm.doc.custom_format) { - frm.add_custom_button(__("Edit Format"), function() { - if(!frm.doc.doc_type) { - msgprint(__("Please select DocType first")); - return; - } - frappe.set_route("print-format-builder", frm.doc.name); - }); - } + frm.trigger('render_buttons'); } }) From bfadc9f81fb6a188dc13d79388f3fa9ced37bf56 Mon Sep 17 00:00:00 2001 From: robert schouten Date: Wed, 7 Dec 2016 13:57:41 +0800 Subject: [PATCH 3/7] move email group with newsletter (#2416) --- frappe/config/desk.py | 5 +++++ frappe/config/setup.py | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frappe/config/desk.py b/frappe/config/desk.py index 0975136596..3280354340 100644 --- a/frappe/config/desk.py +++ b/frappe/config/desk.py @@ -12,6 +12,11 @@ def get_data(): "name": "Newsletter", "description": _("Newsletters to contacts, leads."), }, + { + "type": "doctype", + "name": "Email Group", + "description": _("Email Group List"), + }, { "type": "doctype", "name": "ToDo", diff --git a/frappe/config/setup.py b/frappe/config/setup.py index 2bdeddb564..9b75e6b34f 100644 --- a/frappe/config/setup.py +++ b/frappe/config/setup.py @@ -144,11 +144,6 @@ def get_data(): "name": "Standard Reply", "description": _("Standard replies to common queries.") }, - { - "type": "doctype", - "name": "Email Group", - "description": _("Email Group List"), - }, { "type": "doctype", "name": "Auto Email Report", From cff4af8323b2b73a84cd2663cb2ff3421d095e33 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Wed, 7 Dec 2016 11:31:32 +0530 Subject: [PATCH 4/7] [fix] schduler call fix (#2423) --- frappe/hooks.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frappe/hooks.py b/frappe/hooks.py index 3211a2f96c..1eecca0b4b 100755 --- a/frappe/hooks.py +++ b/frappe/hooks.py @@ -120,8 +120,7 @@ scheduler_events = { "hourly": [ "frappe.model.utils.link_count.update_link_count", 'frappe.model.utils.list_settings.sync_list_settings', - "frappe.utils.error.collect_error_snapshots", - "frappe.integration_broker.doctype.integration_service.integration_service.trigger_integration_service_events" + "frappe.utils.error.collect_error_snapshots" ], "daily": [ "frappe.email.queue.clear_outbox", From acfb0996cfe0fdb39f9a72ae81095a860ac71707 Mon Sep 17 00:00:00 2001 From: robert schouten Date: Wed, 7 Dec 2016 17:10:39 +0800 Subject: [PATCH 5/7] hide disabled reports (#2427) * hide disabled reports * Update moduleview.py --- frappe/desk/moduleview.py | 3 +++ frappe/public/js/frappe/list/list_sidebar.js | 2 +- .../js/frappe/ui/toolbar/awesome_bar.js | 19 +++++++++---------- frappe/utils/user.py | 4 ++-- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/frappe/desk/moduleview.py b/frappe/desk/moduleview.py index 4c73ec1ba1..d8596a2894 100644 --- a/frappe/desk/moduleview.py +++ b/frappe/desk/moduleview.py @@ -158,6 +158,9 @@ def get_config(app, module): for section in config: for item in section["items"]: + if item["type"]=="report" and frappe.db.get_value("Report", item["name"], "disabled")==1: + section["items"].remove(item) + continue if not "label" in item: item["label"] = _(item["name"]) return config diff --git a/frappe/public/js/frappe/list/list_sidebar.js b/frappe/public/js/frappe/list/list_sidebar.js index 72caaeb6a7..19b8fd6737 100644 --- a/frappe/public/js/frappe/list/list_sidebar.js +++ b/frappe/public/js/frappe/list/list_sidebar.js @@ -69,7 +69,7 @@ frappe.views.ListSidebar = Class.extend({ var add_reports = function(reports) { $.each(reports, function(name, r) { - if(!r.ref_doctype || r.ref_doctype==me.doctype && !r.disabled) { + if(!r.ref_doctype || r.ref_doctype==me.doctype) { var report_type = r.report_type==='Report Builder' ? 'Report/' + r.ref_doctype : 'query-report'; var route = r.route || report_type + '/' + r.name; diff --git a/frappe/public/js/frappe/ui/toolbar/awesome_bar.js b/frappe/public/js/frappe/ui/toolbar/awesome_bar.js index 6c2abdf493..b0c550ecaf 100644 --- a/frappe/public/js/frappe/ui/toolbar/awesome_bar.js +++ b/frappe/public/js/frappe/ui/toolbar/awesome_bar.js @@ -278,17 +278,16 @@ frappe.search.verbs = [ frappe.search.find(keys(frappe.boot.user.all_reports), txt, function(match) { var report = frappe.boot.user.all_reports[match]; var route = []; - if(!report.disabled) - if(report.report_type == "Report Builder") - route = ["Report", report.ref_doctype, match]; - else - route = ["query-report", match]; + if(report.report_type == "Report Builder") + route = ["Report", report.ref_doctype, match]; + else + route = ["query-report", match]; - return { - label: __("Report {0}", [__(match).bold()]), - value: __("Report {0}", [__(match)]), - route: route - } + return { + label: __("Report {0}", [__(match).bold()]), + value: __("Report {0}", [__(match)]), + route: route + } }); }, diff --git a/frappe/utils/user.py b/frappe/utils/user.py index 940546d9aa..15367f988e 100755 --- a/frappe/utils/user.py +++ b/frappe/utils/user.py @@ -205,8 +205,8 @@ class UserPermissions: return d def get_all_reports(self): - reports = frappe.db.sql("""select name, report_type, ref_doctype, disabled from tabReport - where ref_doctype in ('{0}')""".format("', '".join(self.can_get_report)), as_dict=1) + reports = frappe.db.sql("""select name, report_type, ref_doctype from tabReport + where ref_doctype in ('{0}') and disabled = 0""".format("', '".join(self.can_get_report)), as_dict=1) return frappe._dict((d.name, d) for d in reports) From 5c3213ffa866ab07d597b1f4abd747228d4ea0e9 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 8 Dec 2016 12:18:04 +0530 Subject: [PATCH 6/7] Update report.py --- frappe/core/doctype/report/report.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frappe/core/doctype/report/report.py b/frappe/core/doctype/report/report.py index 64083046fe..3ed44a24a0 100644 --- a/frappe/core/doctype/report/report.py +++ b/frappe/core/doctype/report/report.py @@ -39,9 +39,10 @@ class Report(Document): self.export_doc() def update_report_json(self): - data = json.loads(self.json) - data["add_total_row"] = self.add_total_row - self.json = json.dumps(data) + if self.json: + data = json.loads(self.json) + data["add_total_row"] = self.add_total_row + self.json = json.dumps(data) def export_doc(self): if frappe.flags.in_import: From 203ca857db7f9b69237118a91fac5ec996743f53 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 8 Dec 2016 13:02:19 +0600 Subject: [PATCH 7/7] bumped to version 7.1.24 --- frappe/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index e26ca0e9d3..3e796f8929 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -13,7 +13,7 @@ import os, sys, importlib, inspect, json from .exceptions import * from .utils.jinja import get_jenv, get_template, render_template -__version__ = '7.1.23' +__version__ = '7.1.24' __title__ = "Frappe Framework" local = Local()