Skip to content

Commit

Permalink
fix: format filter values in report print view (backport frappe#20717) (
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Apr 19, 2023
1 parent c852197 commit 6fc359f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions frappe/public/js/frappe/views/reports/query_report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1337,10 +1337,10 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
get_filters_html_for_print() {
const applied_filters = this.get_filter_values();
return Object.keys(applied_filters)
.map(fieldname => {
const label = frappe.query_report.get_filter(fieldname).df.label;
.map((fieldname) => {
const docfield = frappe.query_report.get_filter(fieldname).df;
const value = applied_filters[fieldname];
return `<h6>${__(label)}: ${value}</h6>`;
return `<h6>${__(docfield.label)}: ${frappe.format(value, docfield)}</h6>`;
})
.join('');
}
Expand Down
15 changes: 8 additions & 7 deletions frappe/public/js/frappe/views/reports/report_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1295,13 +1295,14 @@ frappe.views.ReportView = class ReportView extends frappe.views.ListView {
get_filters_html_for_print() {
const filters = this.filter_area.get();

return filters.map(f => {
const [doctype, fieldname, condition, value] = f;
if (condition !== '=') return '';

const label = frappe.meta.get_label(doctype, fieldname);
return `<h6>${__(label)}: ${value}</h6>`;
}).join('');
return filters
.map((f) => {
const [doctype, fieldname, condition, value] = f;
if (condition !== '=') return '';
const docfield = frappe.meta.get_docfield(doctype, fieldname);
return `<h6>${__(docfield.label)}: ${frappe.format(value, docfield)}</h6>`;
})
.join("");
}

get_columns_totals(data) {
Expand Down

0 comments on commit 6fc359f

Please sign in to comment.