feat: Function for linking reports with filters (#6718)
This commit is contained in:
parent
d4c2ff74c7
commit
817d0744f8
1 changed files with 20 additions and 0 deletions
|
|
@ -745,6 +745,20 @@ def get_link_to_form(doctype, name, label=None):
|
|||
|
||||
return """<a href="{0}">{1}</a>""".format(get_url_to_form(doctype, name), label)
|
||||
|
||||
def get_link_to_report(name, label=None, report_type=None, doctype=None, filters=None):
|
||||
if not label: label = name
|
||||
|
||||
if filters:
|
||||
conditions = []
|
||||
for k,v in iteritems(filters):
|
||||
conditions.append(str(k)+"="+str(v))
|
||||
|
||||
filters = "&".join(conditions)
|
||||
|
||||
return """<a href="{0}">{1}</a>""".format(get_url_to_report_with_filters(name, filters, report_type, doctype), label)
|
||||
else:
|
||||
return """<a href="{0}">{1}</a>""".format(get_url_to_report(name, report_type, doctype), label)
|
||||
|
||||
def get_url_to_form(doctype, name):
|
||||
return get_url(uri = "desk#Form/{0}/{1}".format(quoted(doctype), quoted(name)))
|
||||
|
||||
|
|
@ -757,6 +771,12 @@ def get_url_to_report(name, report_type = None, doctype = None):
|
|||
else:
|
||||
return get_url(uri = "desk#query-report/{0}".format(quoted(name)))
|
||||
|
||||
def get_url_to_report_with_filters(name, filters, report_type = None, doctype = None):
|
||||
if report_type == "Report Builder":
|
||||
return get_url(uri = "desk#Report/{0}/{1}?{2}".format(quoted(doctype), quoted(name), filters))
|
||||
else:
|
||||
return get_url(uri = "desk#query-report/{0}?{1}".format(quoted(name), filters))
|
||||
|
||||
operator_map = {
|
||||
# startswith
|
||||
"^": lambda a, b: (a or "").startswith(b),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue