瀏覽代碼

Fixes in reportview filter conditions

version-14
Nabin Hait 11 年之前
父節點
當前提交
fc6d904c9a
共有 1 個文件被更改,包括 9 次插入11 次删除
  1. +9
    -11
      webnotes/widgets/reportview.py

+ 9
- 11
webnotes/widgets/reportview.py 查看文件

@@ -184,20 +184,18 @@ 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:
if isinstance(f[3], basestring):
df = webnotes.local.reportview_doctypes[f[0]].get({"doctype": "DocField",
"fieldname": f[1]})
df = webnotes.local.reportview_doctypes[f[0]].get({"doctype": "DocField",
"fieldname": f[1]})
if df and df[0].fieldtype in ["Float", "Int", "Currency", "Percent"]:
val, default_null_val = flt(f[3]), "0"
else:
val, default_null_val = ("'" + f[3].replace("'", "\\'") + "'"), '""'
if f[2] == "like" or (isinstance(f[3], basestring) and
(not df or df[0].fieldtype not in ["Float", "Int", "Currency", "Percent"])):
value, default_val = ("'" + f[3].replace("'", "\\'") + "'"), '""'
else: else:
val, default_null_val = f[3], '0'
value, default_val = flt(f[3]), 0
conditions.append('ifnull({tname}.{fname}, {default_val}) {operator} {value}'.format( conditions.append('ifnull({tname}.{fname}, {default_val}) {operator} {value}'.format(
tname=tname, fname=f[1], default_val=default_null_val, operator=f[2],
value=cstr(val)))
tname=tname, fname=f[1], default_val=default_val, operator=f[2],
value=value))
def build_match_conditions(doctype, fields=None, as_condition=True): def build_match_conditions(doctype, fields=None, as_condition=True):
"""add match conditions if applicable""" """add match conditions if applicable"""


Loading…
取消
儲存