count issue if child table exists in filter fix

This commit is contained in:
Zlash65 2017-10-27 17:08:51 +05:30
parent fd36f1f01c
commit 7d2e30d529
2 changed files with 19 additions and 5 deletions

View file

@ -581,10 +581,24 @@ def get_list(doctype, *args, **kwargs):
@frappe.whitelist()
def get_count(doctype, filters=None):
if filters:
filters = json.loads(filters)
if isinstance(filters, list):
filters = frappe.utils.make_filter_dict(filters)
return frappe.db.count(doctype, filters=filters)
@frappe.whitelist()
def set_filters(doctype, filters=None):
count = []
if filters:
filters = json.loads(filters)
for d in filters:
filt = []
if d[0] != doctype:
doctype = d[0]
filt.append(d)
count.append(get_count(doctype, filt))
if count:
return min(count)
return count

View file

@ -362,13 +362,13 @@ frappe.views.ListRenderer = Class.extend({
const $header_right = this.list_view.list_header.find('.list-item__content--activity');
frappe.call({
method: 'frappe.model.db_query.get_count',
method: 'frappe.model.db_query.set_filters',
args: {
doctype: this.doctype,
filters: this.list_view.get_filters_args()
}
}).then(r => {
const count = r.message;
const count = r.message ? r.message : current_count;
const $html = $(`<span>${current_count} of ${count}</span>`);
$html.css({