diff --git a/core/page/data_import_tool/data_import_tool.py b/core/page/data_import_tool/data_import_tool.py
index 44940353d8..524b5feab3 100644
--- a/core/page/data_import_tool/data_import_tool.py
+++ b/core/page/data_import_tool/data_import_tool.py
@@ -90,8 +90,9 @@ def get_template():
columns = [key]
def append_row(t, mandatory):
- docfield = getdocfield(t)
- if docfield and ((mandatory and docfield.reqd) or (not mandatory and not docfield.reqd)) \
+ docfield = doctype_dl.get_field(t)
+
+ if docfield and ((mandatory and docfield.reqd) or not (mandatory or docfield.reqd)) \
and (t not in ('parenttype', 'trash_reason')) and not docfield.hidden:
fieldrow.append(t)
labelrow.append(docfield.label)
@@ -129,11 +130,6 @@ def get_template():
webnotes.response['type'] = 'csv'
webnotes.response['doctype'] = doctype
-def getdocfield(fieldname):
- """get docfield from doclist of doctype"""
- l = [d for d in doctype_dl if d.doctype=='DocField' and d.fieldname==fieldname]
- return l and l[0] or None
-
@webnotes.whitelist(allow_roles=['System Manager', 'Administrator'])
def upload():
"""upload data"""
@@ -276,7 +272,7 @@ def check_record(d, parenttype=None):
doctype_dl = webnotes.model.doctype.get(d.doctype)
for key in d:
- docfield = getdocfield(key)
+ docfield = doctype_dl.get_field(key)
val = d[key]
if docfield:
if docfield.reqd and (val=='' or val==None):
diff --git a/public/js/wn/views/listview.js b/public/js/wn/views/listview.js
index 7a23c2d242..71b194b0e6 100644
--- a/public/js/wn/views/listview.js
+++ b/public/js/wn/views/listview.js
@@ -270,9 +270,11 @@ wn.views.ListView = Class.extend({
// title
if(!in_list(["avatar", "_user_tags", "check"], opts.content)) {
- $(parent).attr("title", (opts.title || opts.content) + ": "
- + (data[opts.content] || "Not Set"))
- .tooltip();
+ if($(parent).attr("title")==undefined) {
+ $(parent).attr("title", (opts.title || opts.content) + ": "
+ + (data[opts.content] || "Not Set"))
+ }
+ $(parent).tooltip();
}
},
@@ -347,10 +349,10 @@ wn.views.ListView = Class.extend({
label: label
}
$(parent).append(repl('\
\
', args));
+ $(parent).attr("title", repl("%(percent)s% %(label)s", args));
},
render_icon: function(parent, icon_class, label) {
var icon_html = "";
diff --git a/webnotes/model/doc.py b/webnotes/model/doc.py
index 4386a404c0..f0508ea1d0 100755
--- a/webnotes/model/doc.py
+++ b/webnotes/model/doc.py
@@ -252,34 +252,13 @@ class Document:
if not self.name:
self.name = make_autoname('#########', self.doctype)
- def _validate_name(self, case):
- if webnotes.conn.sql('select name from `tab%s` where name=%s' % (self.doctype,'%s'), self.name):
- raise NameError, 'Name %s already exists' % self.name
-
- # no name
- if not self.name: return 'No Name Specified for %s' % self.doctype
-
- # new..
- if self.name.startswith('New '+self.doctype):
- raise NameError, 'There were some errors setting the name, please contact the administrator'
-
- if case=='Title Case': self.name = self.name.title()
- if case=='UPPER CASE': self.name = self.name.upper()
-
- self.name = self.name.strip() # no leading and trailing blanks
-
- forbidden = ['%', "'", '"', '#', '*', '?', '`']
- for f in forbidden:
- if f in self.name:
- webnotes.msgprint('%s not allowed in ID (name)' % f, raise_exception =1)
-
def _insert(self, autoname, istable, case='', make_autoname=1, keep_timestamps=False):
# set name
if make_autoname:
self._set_name(autoname, istable)
# validate name
- self._validate_name(case)
+ validate_name(self.doctype, self.name, case)
# insert!
if not keep_timestamps:
@@ -686,4 +665,27 @@ def copy_common_fields(from_doc, to_doc):
continue
if doctype_list.get_field(fieldname) and to_doc.fields[fieldname] != value:
- to_doc.fields[fieldname] = value
\ No newline at end of file
+ to_doc.fields[fieldname] = value
+
+def validate_name(doctype, name, case=None):
+ if webnotes.conn.sql('select name from `tab%s` where name=%s' % (doctype,'%s'), name):
+ raise NameError, 'Name %s already exists' % name
+
+ # no name
+ if not name: return 'No Name Specified for %s' % doctype
+
+ # new..
+ if name.startswith('New '+doctype):
+ raise NameError, 'There were some errors setting the name, please contact the administrator'
+
+ if case=='Title Case': name = name.title()
+ if case=='UPPER CASE': name = name.upper()
+
+ name = name.strip() # no leading and trailing blanks
+
+ forbidden = ['%', "'", '"', '#', '*', '?', '`']
+ for f in forbidden:
+ if f in name:
+ webnotes.msgprint('%s not allowed in ID (name)' % f, raise_exception =1)
+
+ return name
diff --git a/webnotes/model/rename_doc.py b/webnotes/model/rename_doc.py
index 5f83470683..3f5da9d311 100644
--- a/webnotes/model/rename_doc.py
+++ b/webnotes/model/rename_doc.py
@@ -3,6 +3,7 @@ import webnotes
from webnotes import _
import webnotes.utils
import webnotes.model.doctype
+from webnotes.model.doc import validate_name
@webnotes.whitelist()
def rename_doc(doctype, old, new, force=False, merge=False):
@@ -16,7 +17,7 @@ def rename_doc(doctype, old, new, force=False, merge=False):
# get doclist of given doctype
doclist = webnotes.model.doctype.get(doctype)
- validate_rename(doctype, new, doclist, merge, force)
+ new = validate_rename(doctype, new, doclist, merge, force)
# call on_rename
obj = webnotes.get_obj(doctype, old)
@@ -57,6 +58,7 @@ def rename_parent_and_child(doctype, old, new, doclist):
def validate_rename(doctype, new, doclist, merge, force):
exists = webnotes.conn.exists(doctype, new)
+
if merge and not exists:
webnotes.msgprint("%s: %s does not exist, select a new target to merge." % (doctype, new), raise_exception=1)
@@ -68,6 +70,11 @@ def validate_rename(doctype, new, doclist, merge, force):
if not force and not doclist[0].allow_rename:
webnotes.msgprint("%s cannot be renamed" % doctype, raise_exception=1)
+
+ # validate naming like it's done in doc.py
+ new = validate_name(doctype, new)
+
+ return new
def rename_doctype(doctype, old, new, force=False):
# change options for fieldtype Table