Merge branch 'master' of github.com:webnotes/wnframework
This commit is contained in:
commit
184ceffdbc
11 changed files with 39 additions and 34 deletions
|
|
@ -78,7 +78,8 @@ class DocType:
|
|||
|
||||
for d in self.get_ref_doclist():
|
||||
if d.doctype=='DocField':
|
||||
new = addchild(self.doc, 'fields', 'Customize Form Field', 1, self.doclist)
|
||||
new = addchild(self.doc, 'fields', 'Customize Form Field',
|
||||
self.doclist)
|
||||
self.set(
|
||||
{
|
||||
'list': self.docfield_properties,
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ class DocType:
|
|||
temp_doclist = webnotes.model.doctype.get(self.doc.name)
|
||||
if 'file_list' not in [d.fieldname for d in temp_doclist if \
|
||||
d.doctype=='DocField']:
|
||||
new = self.doc.addchild('fields', 'DocField', 1, self.doclist)
|
||||
new = self.doc.addchild('fields', 'DocField', self.doclist)
|
||||
new.label = 'File List'
|
||||
new.fieldtype = 'Text'
|
||||
new.fieldname = 'file_list'
|
||||
|
|
@ -151,7 +151,7 @@ class DocType:
|
|||
max_idx = max_idx and max_idx or 0
|
||||
if 'amended_from' not in [d.fieldname for d in temp_doclist if \
|
||||
d.doctype=='DocField']:
|
||||
new = self.doc.addchild('fields', 'DocField', 1, self.doclist)
|
||||
new = self.doc.addchild('fields', 'DocField', self.doclist)
|
||||
new.label = 'Amended From'
|
||||
new.fieldtype = 'Link'
|
||||
new.fieldname = 'amended_from'
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ class DocType:
|
|||
|
||||
# Add a row in target table in 'To DocType' and returns obj
|
||||
if t['to_table'] != self.doc.to_doctype:
|
||||
to_doc_obj = addchild(to_doc, t['to_field'], t['to_table'], 1, doclist)
|
||||
to_doc_obj = addchild(to_doc, t['to_field'], t['to_table'], doclist)
|
||||
else:
|
||||
to_doc_obj = to_doc
|
||||
|
||||
|
|
|
|||
|
|
@ -919,6 +919,9 @@ _f.Frm.prototype.save = function(save_action, callback, btn) {
|
|||
doclist.save(save_action || "Save", function(r) {
|
||||
if(!r.exc) {
|
||||
me.refresh();
|
||||
if(save_action==="Save") {
|
||||
me.runclientscript("after_save", me.doctype, me.docname);
|
||||
}
|
||||
}
|
||||
callback && callback(r);
|
||||
}, btn);
|
||||
|
|
@ -944,8 +947,8 @@ _f.Frm.prototype.savecancel = function(btn) {
|
|||
doclist.cancel(function(r) {
|
||||
if(!r.exc) {
|
||||
me.refresh();
|
||||
me.runclientscript("after_cancel", me.doctype, me.docname);
|
||||
}
|
||||
me.runclientscript("after_cancel", me.doctype, me.docname);
|
||||
}, btn);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,21 +83,23 @@ _f.FormGrid.prototype.make_tbar_link = function(parent, label, fn, icon) {
|
|||
}
|
||||
|
||||
_f.FormGrid.prototype.make_columns = function() {
|
||||
var gl = wn.meta.docfield_list[this.field.df.options];
|
||||
|
||||
if(!gl) {
|
||||
alert('Table details not found "'+this.field.df.options+'"');
|
||||
}
|
||||
|
||||
gl.sort(function(a,b) { return a.idx - b.idx});
|
||||
|
||||
var p = this.field.perm;
|
||||
for(var i=0;i<gl.length;i++) {
|
||||
if(p[this.field.df.permlevel] && p[this.field.df.permlevel][READ]) { // if read
|
||||
if(p[this.field.df.permlevel] && p[this.field.df.permlevel][READ]) { // if read
|
||||
var gl = wn.meta.docfield_list[this.field.df.options];
|
||||
|
||||
if(!gl) {
|
||||
alert('Table details not found "'+this.field.df.options+'"');
|
||||
}
|
||||
|
||||
gl.sort(function(a,b) { return a.idx - b.idx});
|
||||
|
||||
for(var i=0;i<gl.length;i++) {
|
||||
this.insert_column(this.field.df.options, gl[i].fieldname, gl[i].fieldtype, gl[i].label, gl[i].width, gl[i].options, this.field.perm, gl[i].reqd);
|
||||
|
||||
// hide it even if it is hidden at start..
|
||||
// so that it can be brought back once
|
||||
if(gl[i].hidden) {
|
||||
// also, hide column if no permissions found
|
||||
if(gl[i].hidden || !(p[gl[i].permlevel] && p[gl[i].permlevel][READ])) {
|
||||
this.set_column_disp(gl[i].fieldname, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ $.extend(wn.user, {
|
|||
// add missing modules - they will be hidden anyways by the view
|
||||
$.each(wn.modules, function(m, data) {
|
||||
if(modules_list.indexOf(m)==-1) {
|
||||
modules_list.append(m);
|
||||
modules_list.push(m);
|
||||
}
|
||||
});
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -40,8 +40,10 @@ wn.print.Table = Class.extend({
|
|||
this.make();
|
||||
},
|
||||
get_columns: function() {
|
||||
var perms = wn.perm.get_perm(this.doctype, this.docname);
|
||||
return ['Sr'].concat($.map(wn.meta.docfield_list[this.tabletype], function(df) {
|
||||
return cint(df.print_hide) ? null : df.fieldname;
|
||||
return (cint(df.print_hide) || !(perms[df.permlevel] &&
|
||||
perms[df.permlevel][READ])) ? null : df.fieldname;
|
||||
}));
|
||||
},
|
||||
get_data: function() {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ def copytables(srctype, src, srcfield, tartype, tar, tarfield, srcfields, tarfie
|
|||
l = []
|
||||
data = webnotes.model.doc.getchildren(src.name, srctype, srcfield)
|
||||
for d in data:
|
||||
newrow = webnotes.model.doc.addchild(tar, tarfield, tartype, local = 1)
|
||||
newrow = webnotes.model.doc.addchild(tar, tarfield, tartype)
|
||||
newrow.idx = d.idx
|
||||
|
||||
for i in range(len(srcfields)):
|
||||
|
|
|
|||
|
|
@ -449,6 +449,9 @@ class Document:
|
|||
make_autoname, keep_timestamps = keep_timestamps)
|
||||
if r:
|
||||
return r
|
||||
|
||||
elif not webnotes.conn.exists(self.doctype, self.name):
|
||||
webnotes.msgprint("""This document was updated before your change. Please refresh before saving.""", raise_exception=1)
|
||||
|
||||
# save the values
|
||||
self._update_values(res.get('issingle'),
|
||||
|
|
@ -575,7 +578,7 @@ class Document:
|
|||
|
||||
return webnotes.doclist(doclist)
|
||||
|
||||
def addchild(self, fieldname, childtype = '', local=0, doclist=None):
|
||||
def addchild(self, fieldname, childtype = '', doclist=None):
|
||||
"""
|
||||
Returns a child record of the give `childtype`.
|
||||
|
||||
|
|
@ -590,12 +593,8 @@ class Document:
|
|||
d.docstatus = 0;
|
||||
d.name = ''
|
||||
d.owner = webnotes.session['user']
|
||||
d.fields['__islocal'] = 1 # for Client to identify unsaved doc
|
||||
|
||||
if local:
|
||||
d.fields['__islocal'] = 1 # for Client to identify unsaved doc
|
||||
else:
|
||||
d.save(new=1)
|
||||
|
||||
if doclist != None:
|
||||
doclist.append(d)
|
||||
|
||||
|
|
@ -612,7 +611,7 @@ class Document:
|
|||
return ret
|
||||
|
||||
|
||||
def addchild(parent, fieldname, childtype = '', local=0, doclist=None):
|
||||
def addchild(parent, fieldname, childtype = '', doclist=None):
|
||||
"""
|
||||
|
||||
Create a child record to the parent doc.
|
||||
|
|
@ -620,11 +619,11 @@ def addchild(parent, fieldname, childtype = '', local=0, doclist=None):
|
|||
Example::
|
||||
|
||||
c = Document('Contact','ABC')
|
||||
d = addchild(c, 'contact_updates', 'Contact Update', local = 1)
|
||||
d = addchild(c, 'contact_updates', 'Contact Update')
|
||||
d.last_updated = 'Phone call'
|
||||
d.save(1)
|
||||
"""
|
||||
return parent.addchild(fieldname, childtype, local, doclist)
|
||||
return parent.addchild(fieldname, childtype, doclist)
|
||||
|
||||
# Naming
|
||||
# ------
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ def check_if_doc_is_linked(dt, dn):
|
|||
webnotes.msgprint("Cannot delete %s <b>%s</b> because it is linked in %s <b>%s</b>" % (dt, dn, item[0][2] or link_dt, item[0][1] or item[0][0]), raise_exception=1)
|
||||
|
||||
|
||||
def round_doc(doc, precision_map):
|
||||
def round_floats_in_doc(doc, precision_map):
|
||||
from webnotes.utils import flt
|
||||
for fieldname, precision in precision_map.items():
|
||||
doc.fields[fieldname] = flt(doc.fields.get(fieldname), precision)
|
||||
|
|
@ -261,4 +261,4 @@ def set_default(doc, key):
|
|||
where `%s`=%s and name!=%s""" % (doc.doctype, key, "%s", "%s"),
|
||||
(doc.fields.get(key), doc.name))
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class ModelWrapper:
|
|||
docs[i] = Document(fielddata=d)
|
||||
|
||||
self.docs = self.doclist = webnotes.doclist(docs)
|
||||
self.doc, self.children = docs[0], webnotes.doclist(docs[1:])
|
||||
self.doc, self.children = self.doclist[0], self.doclist[1:]
|
||||
if self.obj:
|
||||
self.obj.doclist = self.doclist
|
||||
self.obj.doc = self.doc
|
||||
|
|
@ -225,9 +225,7 @@ class ModelWrapper:
|
|||
"""
|
||||
child_map = {}
|
||||
for d in self.children:
|
||||
if (d.fields.has_key('parent') and d.fields.get('parent')) or \
|
||||
(d.fields.has_key("parentfield") and d.fields.get("parentfield")):
|
||||
# if d.parent:
|
||||
if d.fields.get("parent") or d.fields.get("parentfield"):
|
||||
d.parent = self.doc.name # rename if reqd
|
||||
d.parenttype = self.doc.doctype
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue