@@ -13,7 +13,7 @@ import os, sys, importlib, inspect, json | |||||
from .exceptions import * | from .exceptions import * | ||||
from .utils.jinja import get_jenv, get_template, render_template | from .utils.jinja import get_jenv, get_template, render_template | ||||
__version__ = '8.0.60' | |||||
__version__ = '8.0.61' | |||||
__title__ = "Frappe Framework" | __title__ = "Frappe Framework" | ||||
local = Local() | local = Local() | ||||
@@ -3,7 +3,7 @@ | |||||
frappe.ui.form.on('Page', { | frappe.ui.form.on('Page', { | ||||
refresh: function(frm) { | refresh: function(frm) { | ||||
if(!frappe.boot.developer_mode) { | |||||
if(!frappe.boot.developer_mode && user != 'Administrator') { | |||||
// make the document read-only | // make the document read-only | ||||
frm.set_read_only(); | frm.set_read_only(); | ||||
} | } | ||||
@@ -54,7 +54,7 @@ cur_frm.cscript.refresh = function(doc) { | |||||
frappe.ui.form.on('Report', { | frappe.ui.form.on('Report', { | ||||
refresh: function(frm) { | refresh: function(frm) { | ||||
if(!frappe.boot.developer_mode) { | |||||
if(!frappe.boot.developer_mode && user != 'Administrator') { | |||||
// make the document read-only | // make the document read-only | ||||
frm.set_read_only(); | frm.set_read_only(); | ||||
} | } | ||||
@@ -100,12 +100,18 @@ class Report(Document): | |||||
data = frappe.desk.query_report.run(self.name, filters=filters, user=user) | data = frappe.desk.query_report.run(self.name, filters=filters, user=user) | ||||
for d in data.get('columns'): | for d in data.get('columns'): | ||||
if isinstance(d, dict): | if isinstance(d, dict): | ||||
columns.append(frappe._dict(d)) | |||||
col = frappe._dict(d) | |||||
if not col.fieldname: | |||||
col.fieldname = col.label | |||||
columns.append(col) | |||||
else: | else: | ||||
fieldtype, options = "Data", None | |||||
parts = d.split(':') | parts = d.split(':') | ||||
fieldtype, options = parts[1], None | |||||
if fieldtype and '/' in fieldtype: | |||||
fieldtype, options = fieldtype.split('/') | |||||
if len(parts) > 1: | |||||
if parts[1]: | |||||
fieldtype, options = parts[1], None | |||||
if fieldtype and '/' in fieldtype: | |||||
fieldtype, options = fieldtype.split('/') | |||||
columns.append(frappe._dict(label=parts[0], fieldtype=fieldtype, fieldname=parts[0])) | columns.append(frappe._dict(label=parts[0], fieldtype=fieldtype, fieldname=parts[0])) | ||||
@@ -145,7 +151,7 @@ class Report(Document): | |||||
for c in columns] | for c in columns] | ||||
out = out + [list(d) for d in result] | out = out + [list(d) for d in result] | ||||
if as_dict: | if as_dict: | ||||
data = [] | data = [] | ||||
for row in out: | for row in out: | ||||
@@ -155,7 +161,6 @@ class Report(Document): | |||||
_row[columns[i].get('fieldname')] = val | _row[columns[i].get('fieldname')] = val | ||||
else: | else: | ||||
data = out | data = out | ||||
return columns, data | return columns, data | ||||
@@ -104,7 +104,7 @@ def run(report_name, filters=None, user=None): | |||||
if cint(report.add_total_row) and result: | if cint(report.add_total_row) and result: | ||||
result = add_total_row(result, columns) | result = add_total_row(result, columns) | ||||
return { | return { | ||||
"result": result, | "result": result, | ||||
"columns": columns, | "columns": columns, | ||||
@@ -129,6 +129,8 @@ def export_query(): | |||||
file_format_type = data["file_format_type"] | file_format_type = data["file_format_type"] | ||||
if isinstance(data.get("visible_idx"), basestring): | if isinstance(data.get("visible_idx"), basestring): | ||||
visible_idx = json.loads(data.get("visible_idx")) | visible_idx = json.loads(data.get("visible_idx")) | ||||
else: | |||||
visible_idx = None | |||||
if file_format_type == "Excel": | if file_format_type == "Excel": | ||||
@@ -154,7 +156,8 @@ def export_query(): | |||||
result = result + data.result | result = result + data.result | ||||
# filter rows by slickgrid's inline filter | # filter rows by slickgrid's inline filter | ||||
result = [x for idx, x in enumerate(result) if idx == 0 or idx in visible_idx] | |||||
if visible_idx: | |||||
result = [x for idx, x in enumerate(result) if idx == 0 or idx in visible_idx] | |||||
from frappe.utils.xlsxutils import make_xlsx | from frappe.utils.xlsxutils import make_xlsx | ||||
xlsx_file = make_xlsx(result, "Query Report") | xlsx_file = make_xlsx(result, "Query Report") | ||||
@@ -182,9 +185,12 @@ def add_total_row(result, columns, meta = None): | |||||
else: | else: | ||||
col = col.split(":") | col = col.split(":") | ||||
if len(col) > 1: | if len(col) > 1: | ||||
fieldtype = col[1] | |||||
if "/" in fieldtype: | |||||
fieldtype, options = fieldtype.split("/") | |||||
if col[1]: | |||||
fieldtype = col[1] | |||||
if "/" in fieldtype: | |||||
fieldtype, options = fieldtype.split("/") | |||||
else: | |||||
fieldtype = "Data" | |||||
else: | else: | ||||
fieldtype = col.get("fieldtype") | fieldtype = col.get("fieldtype") | ||||
options = col.get("options") | options = col.get("options") | ||||
@@ -210,7 +216,7 @@ def add_total_row(result, columns, meta = None): | |||||
else: | else: | ||||
first_col_fieldtype = columns[0].get("fieldtype") | first_col_fieldtype = columns[0].get("fieldtype") | ||||
if first_col_fieldtype not in ["Currency", "Int", "Float", "Percent"]: | |||||
if first_col_fieldtype not in ["Currency", "Int", "Float", "Percent", "Date"]: | |||||
if first_col_fieldtype == "Link": | if first_col_fieldtype == "Link": | ||||
total_row[0] = "'" + _("Total") + "'" | total_row[0] = "'" + _("Total") + "'" | ||||
else: | else: | ||||
@@ -124,9 +124,9 @@ class AutoEmailReport(Document): | |||||
report_doctype = frappe.db.get_value('Report', self.report, 'ref_doctype') | report_doctype = frappe.db.get_value('Report', self.report, 'ref_doctype') | ||||
report_footer = frappe.render_template(self.get_report_footer(), | report_footer = frappe.render_template(self.get_report_footer(), | ||||
dict(report_url = frappe.utils.get_url_to_report(self.report, self.report_type, report_doctype), | |||||
report_name = self.report, | |||||
edit_report_settings = frappe.utils.get_link_to_form('Auto Email Report', self.name))) | |||||
dict(report_url = frappe.utils.get_url_to_report(self.report, self.report_type, report_doctype), | |||||
report_name = self.report, | |||||
edit_report_settings = frappe.utils.get_link_to_form('Auto Email Report', self.name))) | |||||
message += report_footer | message += report_footer | ||||
@@ -36,7 +36,7 @@ frappe.email_defaults = { | |||||
"use_ssl": 1, | "use_ssl": 1, | ||||
"enable_outgoing": 1, | "enable_outgoing": 1, | ||||
"smtp_server": "smtp.mail.yahoo.com", | "smtp_server": "smtp.mail.yahoo.com", | ||||
"smtp_port": 465, | |||||
"smtp_port": 587, | |||||
"use_tls": 1, | "use_tls": 1, | ||||
"use_imap": 1 | "use_imap": 1 | ||||
}, | }, | ||||
@@ -432,7 +432,8 @@ def prepare_message(email, recipient, recipients_list): | |||||
if email.add_unsubscribe_link and email.reference_doctype: # is missing the check for unsubscribe message but will not add as there will be no unsubscribe url | if email.add_unsubscribe_link and email.reference_doctype: # is missing the check for unsubscribe message but will not add as there will be no unsubscribe url | ||||
unsubscribe_url = get_unsubcribed_url(email.reference_doctype, email.reference_name, recipient, | unsubscribe_url = get_unsubcribed_url(email.reference_doctype, email.reference_name, recipient, | ||||
email.unsubscribe_method, email.unsubscribe_params) | email.unsubscribe_method, email.unsubscribe_params) | ||||
message = message.replace("<!--unsubscribe url-->", quopri.encodestring(unsubscribe_url)) | |||||
if message: | |||||
message = message.replace("<!--unsubscribe url-->", quopri.encodestring(unsubscribe_url)) | |||||
if email.expose_recipients == "header": | if email.expose_recipients == "header": | ||||
pass | pass | ||||
@@ -54,7 +54,7 @@ frappe.form.formatters = { | |||||
var currency = frappe.meta.get_field_currency(docfield, doc); | var currency = frappe.meta.get_field_currency(docfield, doc); | ||||
var precision = docfield.precision || cint(frappe.boot.sysdefaults.currency_precision) || 2; | var precision = docfield.precision || cint(frappe.boot.sysdefaults.currency_precision) || 2; | ||||
return frappe.form.formatters._right((value==null || value==="") | return frappe.form.formatters._right((value==null || value==="") | ||||
? "" : format_currency(value, currency, docfield.precision), options); | |||||
? "" : format_currency(value, currency, precision), options); | |||||
}, | }, | ||||
Check: function(value) { | Check: function(value) { | ||||
if(value) { | if(value) { | ||||
@@ -127,7 +127,9 @@ window.format_number = function(v, format, decimals){ | |||||
function format_currency(v, currency, decimals) { | function format_currency(v, currency, decimals) { | ||||
var format = get_number_format(currency); | var format = get_number_format(currency); | ||||
var symbol = get_currency_symbol(currency); | var symbol = get_currency_symbol(currency); | ||||
var decimals = frappe.boot.sysdefaults.currency_precision || null; | |||||
if(decimals === undefined) { | |||||
decimals = frappe.boot.sysdefaults.currency_precision || null; | |||||
} | |||||
if(symbol) | if(symbol) | ||||
return symbol + " " + format_number(v, format, decimals); | return symbol + " " + format_number(v, format, decimals); | ||||