Skip to content

Commit

Permalink
Merge branch 'hotfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
sahil28297 committed May 7, 2019
2 parents 5c2bd35 + 9bbb5b2 commit 3619cb8
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 33 deletions.
5 changes: 2 additions & 3 deletions frappe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
# public
from .exceptions import *
from .utils.jinja import (get_jenv, get_template, render_template, get_email_from_template, get_jloader)
from .utils.error import get_frame_locals

# Hamless for Python 3
# For Python 2 set default encoding to utf-8
if sys.version[0] == '2':
reload(sys)
sys.setdefaultencoding("utf-8")

__version__ = '11.1.26'
__version__ = '11.1.27'
__title__ = "Frappe Framework"

local = Local()
Expand Down Expand Up @@ -274,7 +273,7 @@ def errprint(msg):
if not request or (not "cmd" in local.form_dict) or conf.developer_mode:
print(msg.encode('utf-8'))

error_log.append({"exc": msg, "locals": get_frame_locals()})
error_log.append({"exc": msg})

def log(msg):
"""Add to `debug_log`.
Expand Down
3 changes: 3 additions & 0 deletions frappe/custom/doctype/customize_form/customize_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def fetch_to_customize(self):
if self.doc_type in core_doctypes_list:
return frappe.msgprint(_("Core DocTypes cannot be customized."))

if meta.issingle:
return frappe.msgprint(_("Single DocTypes cannot be customized."))

if meta.custom:
return frappe.msgprint(_("Only standard DocTypes are allowed to be customized from Customize Form."))

Expand Down
2 changes: 0 additions & 2 deletions frappe/desk/form/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ def savedocs(doc, action):
frappe.get_user().update_recent(doc.doctype, doc.name)
send_updated_docs(doc)
except Exception:
if not frappe.local.message_log:
frappe.msgprint(frappe._('Did not save'))
frappe.errprint(frappe.utils.get_traceback())
raise

Expand Down
2 changes: 1 addition & 1 deletion frappe/public/js/frappe/form/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ frappe.ui.form.Toolbar = Class.extend({
me.frm.savetrash();}, true);
}

if(frappe.user_roles.includes("System Manager")) {
if(frappe.user_roles.includes("System Manager") && me.frm.meta.issingle === 0) {
this.page.add_menu_item(__("Customize"), function() {
frappe.set_route("Form", "Customize Form", {
doc_type: me.frm.doctype
Expand Down
2 changes: 1 addition & 1 deletion frappe/public/js/frappe/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ $.extend(frappe.model, {
tasks.push(() => frappe.model.trigger(key, value, doc));
} else {
// execute link triggers (want to reselect to execute triggers)
if(fieldtype=="Link" && doc) {
if(in_list(["Link", "Dynamic Link"], fieldtype) && doc) {
tasks.push(() => frappe.model.trigger(key, value, doc));
}
}
Expand Down
15 changes: 7 additions & 8 deletions frappe/public/js/frappe/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,16 @@ frappe.after_ajax = function(fn) {

frappe.request.report_error = function(xhr, request_opts) {
var data = JSON.parse(xhr.responseText);
var exc;
if (data.exc) {
var exc = (JSON.parse(data.exc) || []).join("\n");
var locals = (JSON.parse(data.locals) || []).join("\n");
try {
exc = (JSON.parse(data.exc) || []).join("\n");
} catch (e) {
exc = data.exc;
}
delete data.exc;
delete data.locals;
} else {
var exc = "";
locals = "";
exc = "";
}

if (exc) {
Expand Down Expand Up @@ -412,9 +414,6 @@ frappe.request.report_error = function(xhr, request_opts) {
'<h5>Error Report</h5>',
'<pre>' + exc + '</pre>',
'<hr>',
'<h5>Locals</h5>',
'<pre>' + locals + '</pre>',
'<hr>',
'<h5>Request Data</h5>',
'<pre>' + JSON.stringify(request_opts, null, "\t") + '</pre>',
'<hr>',
Expand Down
7 changes: 6 additions & 1 deletion frappe/public/js/legacy/client_script_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,12 @@ _f.Frm.prototype.make_new = function(doctype) {

// set link fields (if found)
frappe.get_meta(doctype).fields.forEach(function(df) {
if(df.fieldtype==='Link' && df.options===me.doctype) {
if(df.fieldtype==='Link' && df.options==="DocType") {
new_doc[df.fieldname] = me.doctype;
}

if((df.fieldtype==='Link' && df.options===me.doctype)
|| (df.fieldtype==='Dynamic Link' && new_doc[df.options] === me.doctype)) {
new_doc[df.fieldname] = me.doc.name;
}
});
Expand Down
2 changes: 1 addition & 1 deletion frappe/public/js/legacy/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ _f.Frm.prototype.trigger_link_fields = function() {
// trigger link fields which have default values set
if (this.is_new() && this.doc.__run_link_triggers) {
$.each(this.fields_dict, function(fieldname, field) {
if (field.df.fieldtype=="Link" && this.doc[fieldname]) {
if (in_list(['Link', 'Dynamic Link'], field.df.fieldtype) && this.doc[fieldname]) {
// triggers add fetch, sets value in model and runs triggers
field.set_value(this.doc[fieldname]);
}
Expand Down
4 changes: 2 additions & 2 deletions frappe/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def to_timedelta(time_str):
else:
return time_str

def add_to_date(date, years=0, months=0, days=0, hours=0, as_string=False, as_datetime=False):
def add_to_date(date, years=0, months=0, days=0, hours=0, seconds=0, as_string=False, as_datetime=False):
"""Adds `days` to the given date"""
from dateutil.relativedelta import relativedelta

Expand All @@ -86,7 +86,7 @@ def add_to_date(date, years=0, months=0, days=0, hours=0, as_string=False, as_da
as_datetime = True
date = parser.parse(date)

date = date + relativedelta(years=years, months=months, days=days, hours=hours)
date = date + relativedelta(years=years, months=months, days=days, hours=hours, seconds=seconds)

if as_string:
if as_datetime:
Expand Down
12 changes: 0 additions & 12 deletions frappe/utils/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,3 @@ def clear_old_snapshots():

def get_error_snapshot_path():
return frappe.get_site_path('error-snapshots')

def get_frame_locals():
traceback = sys.exc_info()[2]
frames = []
if traceback:
frames = inspect.getinnerframes(traceback, context=0)
_locals = ['Locals (most recent call last):']
for frame, filename, lineno, function, __, __ in frames:
if '/apps/' in filename:
_locals.append('File "{}", line {}, in {}\n{}'.format(filename, lineno, function, json.dumps(frame.f_locals, default=str, indent=4)))

return '\n'.join(_locals)
2 changes: 0 additions & 2 deletions frappe/utils/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ def make_logs(response = None):

if frappe.error_log:
response['exc'] = json.dumps([frappe.utils.cstr(d["exc"]) for d in frappe.local.error_log])
if frappe.conf.developer_mode:
response['locals'] = json.dumps([frappe.utils.cstr(d["locals"]) for d in frappe.local.error_log])

if frappe.local.message_log:
response['_server_messages'] = json.dumps([frappe.utils.cstr(d) for
Expand Down

0 comments on commit 3619cb8

Please sign in to comment.