fix: prevent empty filter export in query report (#35357)
This commit is contained in:
parent
fb55c6d95c
commit
dec3f07d01
2 changed files with 22 additions and 22 deletions
|
|
@ -497,10 +497,9 @@ def build_xlsx_data(
|
|||
include_hidden_columns = cint(include_hidden_columns)
|
||||
include_indentation = cint(include_indentation)
|
||||
|
||||
if cint(include_filters):
|
||||
if cint(include_filters) and data.filters:
|
||||
filter_data = []
|
||||
filters = data.filters
|
||||
for filter_name, filter_value in filters.items():
|
||||
for filter_name, filter_value in data.filters.items():
|
||||
if not filter_value:
|
||||
continue
|
||||
filter_value = (
|
||||
|
|
|
|||
|
|
@ -1629,13 +1629,8 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
}
|
||||
|
||||
export_report() {
|
||||
if (this.export_dialog) {
|
||||
this.export_dialog.clear();
|
||||
this.export_dialog.show();
|
||||
return;
|
||||
}
|
||||
|
||||
let extra_fields = [];
|
||||
const extra_fields = [];
|
||||
const applied_filters = this.get_applied_filters(this.get_filter_values());
|
||||
|
||||
if (this.tree_report) {
|
||||
extra_fields.push({
|
||||
|
|
@ -1645,7 +1640,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
});
|
||||
}
|
||||
|
||||
if (this.filters.length > 0) {
|
||||
if (applied_filters && Object.keys(applied_filters).length > 0) {
|
||||
extra_fields.push({
|
||||
label: __("Include filters"),
|
||||
fieldname: "include_filters",
|
||||
|
|
@ -1691,17 +1686,8 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
}) => {
|
||||
this.make_access_log("Export", file_format);
|
||||
|
||||
let filters = this.get_filter_values(true);
|
||||
let boolean_labels = { 1: __("Yes"), 0: __("No") };
|
||||
let applied_filters = {};
|
||||
|
||||
for (const [key, value] of Object.entries(filters)) {
|
||||
const df = frappe.query_report.get_filter(key).df;
|
||||
if (!df.hidden_due_to_dependency) {
|
||||
applied_filters[df.label] =
|
||||
df.fieldtype === "Check" ? boolean_labels[value] : value;
|
||||
}
|
||||
}
|
||||
const filters = this.get_filter_values(true);
|
||||
const applied_filters = this.get_applied_filters(filters);
|
||||
|
||||
if (this.prepared_report_name) {
|
||||
filters.prepared_report_name = this.prepared_report_name;
|
||||
|
|
@ -1742,6 +1728,21 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
this.export_dialog.show();
|
||||
}
|
||||
|
||||
get_applied_filters(filters) {
|
||||
const boolean_labels = { 1: __("Yes"), 0: __("No") };
|
||||
const applied_filters = {};
|
||||
|
||||
for (const [key, value] of Object.entries(filters)) {
|
||||
const df = frappe.query_report.get_filter(key).df;
|
||||
if (!df.hidden_due_to_dependency) {
|
||||
applied_filters[df.label] =
|
||||
df.fieldtype === "Check" ? boolean_labels[value] : value;
|
||||
}
|
||||
}
|
||||
|
||||
return applied_filters;
|
||||
}
|
||||
|
||||
get_data_for_csv(include_indentation) {
|
||||
const rows = this.datatable.bodyRenderer.visibleRows;
|
||||
if (this.raw_data.add_total_row) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue