Hello,
While creating Script Report defined some columns in report.py file…working fine…
But after adding new columns in same array (get_columns() method). doesn’t reflect in output.
what can be wrong here? Reloaded the page several times…
Is there any cache issue or something?.. how to solve it??
Thanks…
If there is an error in .py , it may continue showing previous columns…
can try to run execute from bench console… that will show if any errors in py file…
bench console
from myapp.dotted_path_to_report import execute
execute(filters={"a":"xyz"})
if py is correct it should return columns and data in console
on bench console,
How can I write python code, as you mentioned…Please explain
++++
from myapp.dotted_path_to_report import execute
execute(filters={“a”:“xyz”})
e.g. “Script Report” in accommodation/accommodation/report/internal_voucher/internal_voucher
execute method returns columns, data
def execute(filters=None):
columns = get_columns(filters)
data = get_data(filters)
return columns, data
In a terminal start IPython with
bench console
running execute from console returns results as below
1 Like
To directly check in terminal without entering IPython, can call any function using bench execute with the dotted_path_to_function with args
frappe@box:~/sns-bench$ bench execute accommodation.accommodation.controller.email_all_internal_invoices --args "['Abacus', 'February']"
how to pass object in argument (eg. filters)?
vijaywm
February 6, 2019, 11:07am
8
If you mean in code, check query_report.py
def run(report_name, filters=None, user=None):
if (this.last_ajax) {
this.last_ajax.abort();
}
return new Promise(resolve => {
this.last_ajax = frappe.call({
method: 'frappe.desk.query_report.run',
type: 'GET',
args: {
report_name: this.report_name,
filters: filters,
},
callback: resolve,
always: () => this.page.btn_secondary.prop('disabled', false)
})
}).then(r => {
let data = r.message;
this.hide_status();
clearInterval(this.interval);
this.execution_time = data.execution_time || 0.1;
return {
"script": render_include(script),
"html_format": html_format,
"execution_time": frappe.cache().hget('report_execution_time', report_name) or 0
}
@frappe.whitelist()
@frappe.read_only()
def run(report_name, filters=None, user=None):
report = get_report_doc(report_name)
if not user:
user = frappe.session.user
if not frappe.has_permission(report.ref_doctype, "report"):
frappe.msgprint(_("Must have report permission to access this report."),
raise_exception=True)
result = None