diff --git a/public/js/wn/form/formatters.js b/public/js/wn/form/formatters.js
index 0041ad7c0d..9b62596e16 100644
--- a/public/js/wn/form/formatters.js
+++ b/public/js/wn/form/formatters.js
@@ -11,7 +11,8 @@ wn.form.formatters = {
parseInt(wn.boot.sysdefaults.float_precision) : null;
return "
" +
- format_number(value, null, decimals) + "
";
+ ((value==null || value==="") ? "" :
+ format_number(value, null, decimals)) + "";
},
Int: function(value) {
return cint(value);
diff --git a/webnotes/db.py b/webnotes/db.py
index d3007a7ce3..6db5fdc829 100644
--- a/webnotes/db.py
+++ b/webnotes/db.py
@@ -309,6 +309,9 @@ class Database:
return ret and ((len(ret[0]) > 1 or as_dict) and ret[0] or ret[0][0]) or None
def get_values(self, doctype, filters=None, fieldname="name", ignore=None, as_dict=False, debug=False):
+ if isinstance(filters, list):
+ return self.get_value_for_many_names(doctype, filters, fieldname)
+
fields = fieldname
if fieldname!="*":
if isinstance(fieldname, basestring):
@@ -367,6 +370,11 @@ class Database:
return r
+ def get_value_for_many_names(self, doctype, names, field):
+ names = filter(None, names)
+ return dict(self.sql("select name, `%s` from `tab%s` where name in (%s)" \
+ % (field, doctype, ", ".join(map(lambda n: "'%s'" % n.replace("'", "\'"), names)))))
+
def set_value(self, dt, dn, field, val, modified=None, modified_by=None):
from webnotes.utils import now
if dn and dt!=dn:
diff --git a/webnotes/model/doclist.py b/webnotes/model/doclist.py
index 7bbbc54b1f..9c7c626736 100644
--- a/webnotes/model/doclist.py
+++ b/webnotes/model/doclist.py
@@ -60,6 +60,9 @@ class DocList(list):
break
return DocList(out)
+
+ def get_distinct_values(self, fieldname):
+ return list(set(map(lambda d: d.fields.get(fieldname), self)))
def remove_items(self, filters):
for d in self.get(filters):