[doclist] new pattern / [item] pricelist must be unique / [formatter] show null floats as empty string
This commit is contained in:
parent
8c18d836ba
commit
c03e22c2db
3 changed files with 13 additions and 1 deletions
|
|
@ -11,7 +11,8 @@ wn.form.formatters = {
|
|||
parseInt(wn.boot.sysdefaults.float_precision) : null;
|
||||
|
||||
return "<div style='text-align: right'>" +
|
||||
format_number(value, null, decimals) + "</div>";
|
||||
((value==null || value==="") ? "" :
|
||||
format_number(value, null, decimals)) + "</div>";
|
||||
},
|
||||
Int: function(value) {
|
||||
return cint(value);
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue