Browse Source

Fixes in filter_conditions, null issue

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

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

@@ -169,9 +169,6 @@ def build_filter_conditions(filters, conditions):
if isinstance(f, basestring):
conditions.append(f)
else:
# get doclist of given doctype
doclist.setdefault(f[0], webnotes.model.doctype.get(f[0]))
tname = ('`tab' + f[0] + '`')
if not tname in webnotes.local.reportview_tables:
webnotes.local.reportview_tables.append(tname)
@@ -183,19 +180,18 @@ def build_filter_conditions(filters, conditions):
conditions.append('ifnull(' + tname + '.' + f[1] + ", '') " + f[2] + " " + f[3])
else:
if isinstance(f[3], basestring):
docfield = doclist[f[0]].get({"doctype": "DocField", "fieldname": f[1]})
df = webnotes.local.reportview_doctypes[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])))
if df and df[0].fieldtype in ["Float", "Int", "Currency", "Percent"]:
val, default_null_val = flt(f[3]), 0
else:
f[3] = "'" + f[3].replace("'", "\\'") + "'"
conditions.append('ifnull(' + tname + '.' + f[1] + ", '') " + f[2] + \
" " + cstr(f[3]))
val, default_null_val = ("'" + f[3].replace("'", "\\'") + "'"), ""
else:
conditions.append('ifnull(' + tname + '.' + f[1] + ", 0) " + f[2] \
+ " " + cstr(f[3]))
val, default_null_val = f[3], 0
conditions.append('ifnull(' + tname + '.' + f[1] + ", '"+ default_null_val +"') " \
+ f[2] + " " + cstr(val))
def build_match_conditions(doctype, fields=None, as_condition=True):


Loading…
Cancel
Save