Pārlūkot izejas kodu

[doclist] new pattern / [item] pricelist must be unique / [formatter] show null floats as empty string

version-14
Rushabh Mehta pirms 12 gadiem
vecāks
revīzija
c03e22c2db
3 mainītis faili ar 13 papildinājumiem un 1 dzēšanām
  1. +2
    -1
      public/js/wn/form/formatters.js
  2. +8
    -0
      webnotes/db.py
  3. +3
    -0
      webnotes/model/doclist.py

+ 2
- 1
public/js/wn/form/formatters.js Parādīt failu

@@ -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);


+ 8
- 0
webnotes/db.py Parādīt failu

@@ -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:


+ 3
- 0
webnotes/model/doclist.py Parādīt failu

@@ -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):


Notiek ielāde…
Atcelt
Saglabāt