diff --git a/public/js/legacy/widgets/form/clientscriptAPI.js b/public/js/legacy/widgets/form/clientscriptAPI.js
index f4cba203b6..64b30d558d 100644
--- a/public/js/legacy/widgets/form/clientscriptAPI.js
+++ b/public/js/legacy/widgets/form/clientscriptAPI.js
@@ -234,12 +234,14 @@ _f.Frm.prototype.set_query = function(fieldname, opt1, opt2) {
_f.Frm.prototype.set_value = function(field, value) {
var me = this;
var _set = function(f, v) {
- me.doc[f] = v;
- me.fields_dict[f].refresh();
+ if(me.fields_dict[f]) {
+ me.doc[f] = v;
+ me.fields_dict[f].refresh();
+ }
}
if(typeof field=="string") {
_set(field, value)
- } else {
+ } else if($.isPlainObject(field)) {
$.each(field, function(f, v) {
_set(f, v);
})
@@ -249,11 +251,20 @@ _f.Frm.prototype.set_value = function(field, value) {
_f.Frm.prototype.call = function(opts) {
var me = this;
if(!opts.doc) {
- opts.method = wn.model.get_server_module_name(me.doctype) + "." + opts.method;
+ if(opts.method.indexOf(".")==-1)
+ opts.method = wn.model.get_server_module_name(me.doctype) + "." + opts.method;
opts.original_callback = opts.callback;
opts.callback = function(r) {
- if(typeof (r.message || "")=="object") {
- me.set_value(r.message);
+ if($.isPlainObject(r.message)) {
+ if(opts.child) {
+ // update child doc
+ opts.child = locals[opts.child.doctype][opts.child.name];
+ $.extend(opts.child, r.message);
+ me.fields_dict[opts.child.parentfield].refresh();
+ } else {
+ // update parent doc
+ me.set_value(r.message);
+ }
}
opts.original_callback && opts.original_callback(r);
}
diff --git a/public/js/legacy/widgets/form/form.js b/public/js/legacy/widgets/form/form.js
index e9c907b138..dd8ce3b39c 100644
--- a/public/js/legacy/widgets/form/form.js
+++ b/public/js/legacy/widgets/form/form.js
@@ -298,7 +298,7 @@ _f.Frm.prototype.setup_footer = function() {
_f.Frm.prototype.set_intro = function(txt) {
if(!this.intro_area) {
- this.intro_area = $('
')
+ this.intro_area = $('
')
.insertBefore(this.page_layout.body.firstChild);
}
if(txt) {
@@ -1005,20 +1005,21 @@ _f.Frm.prototype.reload_doc = function() {
}
_f.Frm.prototype.savesubmit = function(btn) {
- var answer = confirm("Permanently Submit "+this.docname+"?");
var me = this;
- if(answer) {
- this.save('Submit', function(r) {
+ wn.confirm("Permanently Submit "+this.docname+"?", function() {
+ me.save('Submit', function(r) {
if(!r.exc && me.cscript.on_submit) {
me.runclientscript('on_submit', me.doctype, me.docname);
}
- }, btn);
- }
+ }, btn);
+ });
}
_f.Frm.prototype.savecancel = function(btn) {
- var answer = confirm("Permanently Cancel "+this.docname+"?");
- if(answer) this.save('Cancel', null, btn);
+ var me = this;
+ wn.confirm("Permanently Submit "+this.docname+"?", function() {
+ me.save('Cancel', null, btn);
+ });
}
// delete the record
diff --git a/public/js/legacy/widgets/form/print_format.js b/public/js/legacy/widgets/form/print_format.js
index 8c00f7b31e..4081fecd30 100644
--- a/public/js/legacy/widgets/form/print_format.js
+++ b/public/js/legacy/widgets/form/print_format.js
@@ -643,4 +643,4 @@ $.extend(_p, {
row.cells[1].className = 'datainputcell';
return row;
}
-});
+});
\ No newline at end of file
diff --git a/public/js/wn/assets.js b/public/js/wn/assets.js
index 87bc621368..b7129a6adb 100644
--- a/public/js/wn/assets.js
+++ b/public/js/wn/assets.js
@@ -64,7 +64,11 @@ wn.assets = {
// localstorage
add: function(src, txt) {
if('localStorage' in window) {
- localStorage.setItem(src, txt);
+ try {
+ localStorage.setItem(src, txt);
+ } catch(e) {
+ console.log("Local Storage quota exceeded?")
+ }
}
},
diff --git a/public/js/wn/perm.js b/public/js/wn/perm.js
index 5178e4593f..5e79296680 100644
--- a/public/js/wn/perm.js
+++ b/public/js/wn/perm.js
@@ -84,16 +84,24 @@ $.extend(wn.perm, {
if(!name) return true;
var out =false;
if(p.match) {
- if(user_defaults[p.match]) {
- for(var i=0;i").html(label)
+ var td = $("| ").html(label)
.appendTo(headrow)
.css(me.head_cell_style)
.css({"width": me.widths[ci] + "%"});
- })
+
+ if(ci==0) {
+ td.css({"min-width": "30px"});
+ }
+ });
$.each(data, function(ri, row) {
var allow = true;
@@ -118,7 +122,7 @@ wn.print.Table = Class.extend({
$.each(me.columns, function(ci, fieldname) {
if(ci==0)
- var value = ri + 1;
+ var value = row.idx;
else
var value = row[fieldname];
@@ -144,7 +148,7 @@ wn.print.Table = Class.extend({
this.widths = $.map(this.columns, function(fieldname, ci) {
df = wn.meta.docfield_map[me.tabletype][fieldname];
return df && df.width ||
- (fieldname=="Sr" ? 20 : 80);
+ (fieldname=="Sr" ? 30 : 80);
})
}
var sum = 0;
diff --git a/public/js/wn/views/reportview.js b/public/js/wn/views/reportview.js
index 078d792dca..cfb97d6c37 100644
--- a/public/js/wn/views/reportview.js
+++ b/public/js/wn/views/reportview.js
@@ -362,7 +362,10 @@ wn.views.ReportView = wn.ui.Listing.extend({
})
},
callback: function(r) {
- if(r.exc) return;
+ if(r.exc) {
+ msgprint("Report was not saved (there were errors)");
+ return;
+ }
if(r.message != me.docname)
wn.set_route('Report2', me.doctype, r.message);
}
diff --git a/webnotes/model/doc.py b/webnotes/model/doc.py
index 67628726d4..9495c96df8 100755
--- a/webnotes/model/doc.py
+++ b/webnotes/model/doc.py
@@ -522,14 +522,17 @@ class Document:
if has_perm and match and match != -1:
for m in match:
- if self.fields.get(m, 'no value') in self._user_defaults.get(m, 'no default'):
+ if ":" in m:
+ document_key, default_key = m.split(":")
+ else:
+ document_key = default_key = m
+
+ if self.fields.get(document_key, 'no value') in \
+ self._user_defaults.get(default_key, 'no default'):
has_perm = 1
break # permission found! break
else:
- has_perm = 0
- if verbose:
- webnotes.msgprint("Value not allowed: '%s' for '%s'" % (self.fields.get(m, 'no value'), m))
-
+ has_perm = 0
return has_perm
diff --git a/webnotes/model/wrapper.py b/webnotes/model/wrapper.py
index b08c8d5860..1af9480a4a 100644
--- a/webnotes/model/wrapper.py
+++ b/webnotes/model/wrapper.py
@@ -129,7 +129,8 @@ class ModelWrapper:
Raises exception if permission is not valid
"""
if not self.doc.check_perm(verbose=1):
- webnotes.msgprint("Not enough permission to save %s" % self.doc.doctype, raise_exception=1)
+ webnotes.msgprint("Not enough permission to save %s" %
+ self.doc.doctype, raise_exception=1)
def check_links(self):
"""
diff --git a/webnotes/profile.py b/webnotes/profile.py
index 70d3b4958e..76b01fb7d7 100644
--- a/webnotes/profile.py
+++ b/webnotes/profile.py
@@ -145,7 +145,7 @@ class Profile:
res = webnotes.conn.sql("""select defkey, defvalue
from `tabDefaultValue` where parent in ("%s") order by idx""" % '", "'.join(roles))
- self.defaults = {'owner': [self.name,]}
+ self.defaults = {'owner': [self.name], "user": [self.name]}
for rec in res:
if not self.defaults.has_key(rec[0]):
diff --git a/webnotes/widgets/reportview.py b/webnotes/widgets/reportview.py
index 636aacfff8..c6b7b6b9b0 100644
--- a/webnotes/widgets/reportview.py
+++ b/webnotes/widgets/reportview.py
@@ -108,7 +108,7 @@ def run_custom_query(data):
query = data['query']
if '%(key)s' in query:
query = query.replace('%(key)s', 'name')
- return webnotes.conn.sql(query, as_dict=1, debug=1)
+ return webnotes.conn.sql(query, as_dict=1)
def load_doctypes():
"""load all doctypes and roles"""
@@ -193,9 +193,15 @@ def build_match_conditions(data, conditions):
if d.doctype == 'DocPerm' and d.parent == data['doctype']:
if d.role in roles:
if d.match: # role applicable
- for v in webnotes.user.defaults.get(d.match, ['**No Match**']):
+ if ':' in d.match:
+ document_key, default_key = d.match.split(":")
+ else:
+ default_key = document_key = d.match
+
+ for v in webnotes.user.defaults.get(default_key, ['**No Match**']):
match_conditions.append('`tab%s`.%s="%s"' % (data['doctype'],
- d.match, v))
+ document_key, v))
+
elif d.read == 1 and d.permlevel == 0:
# don't restrict if another read permission at level 0
# exists without a match restriction
|