Browse Source

Fixes in Filter conditions in reportview to handle null values

version-14
Nabin Hait 11 years ago
parent
commit
3feaa9fd43
1 changed files with 13 additions and 8 deletions
  1. +13
    -8
      webnotes/widgets/reportview.py

+ 13
- 8
webnotes/widgets/reportview.py View File

@@ -182,15 +182,20 @@ def build_filter_conditions(filters, conditions):
f[3] = "(" + ', '.join(opts) + ")" f[3] = "(" + ', '.join(opts) + ")"
conditions.append('ifnull(' + tname + '.' + f[1] + ", '') " + f[2] + " " + f[3]) conditions.append('ifnull(' + tname + '.' + f[1] + ", '') " + f[2] + " " + f[3])
else: else:
fieldtype = doclist[f[0]].get({"doctype": "DocField",
"fieldname": f[1]})[0].fieldtype
if fieldtype in ["Float", "Int", "Currency", "Percent"]:
conditions.append('ifnull(' + tname + '.' + f[1] + ", 0) " + f[2] \
+ " " + cstr(flt(f[3])))
if isinstance(f[3], basestring):
docfield = doclist[f[0]].get({"doctype": "DocField", "fieldname": f[1]})
if docfield and docfield[0].fieldtype in ["Float",
"Int", "Currency", "Percent"]:
conditions.append('ifnull(' + tname + '.' + f[1] + ", 0) " + f[2] \
+ " " + cstr(flt(f[3])))
else:
f[3] = "'" + f[3].replace("'", "\\'") + "'"
conditions.append('ifnull(' + tname + '.' + f[1] + ", '') " + f[2] + \
" " + cstr(f[3]))
else: else:
f[3] = "'" + f[3].replace("'", "\\'") + "'"
conditions.append('ifnull(' + tname + '.' + f[1] + ", '') " + f[2] + \
" " + cstr(f[3]))
conditions.append('ifnull(' + tname + '.' + f[1] + ", 0) " + f[2] \
+ " " + cstr(f[3]))
def build_match_conditions(doctype, fields=None, as_condition=True): def build_match_conditions(doctype, fields=None, as_condition=True):


Loading…
Cancel
Save