Selaa lähdekoodia

count issue if child table exists in filter fix

version-14
Zlash65 7 vuotta sitten
vanhempi
commit
7d2e30d529
2 muutettua tiedostoa jossa 19 lisäystä ja 5 poistoa
  1. +17
    -3
      frappe/model/db_query.py
  2. +2
    -2
      frappe/public/js/frappe/list/list_renderer.js

+ 17
- 3
frappe/model/db_query.py Näytä tiedosto

@@ -581,10 +581,24 @@ def get_list(doctype, *args, **kwargs):


@frappe.whitelist() @frappe.whitelist()
def get_count(doctype, filters=None): def get_count(doctype, filters=None):
if filters:
filters = json.loads(filters)

if isinstance(filters, list): if isinstance(filters, list):
filters = frappe.utils.make_filter_dict(filters) filters = frappe.utils.make_filter_dict(filters)


return frappe.db.count(doctype, filters=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

+ 2
- 2
frappe/public/js/frappe/list/list_renderer.js Näytä tiedosto

@@ -362,13 +362,13 @@ frappe.views.ListRenderer = Class.extend({
const $header_right = this.list_view.list_header.find('.list-item__content--activity'); const $header_right = this.list_view.list_header.find('.list-item__content--activity');


frappe.call({ frappe.call({
method: 'frappe.model.db_query.get_count',
method: 'frappe.model.db_query.set_filters',
args: { args: {
doctype: this.doctype, doctype: this.doctype,
filters: this.list_view.get_filters_args() filters: this.list_view.get_filters_args()
} }
}).then(r => { }).then(r => {
const count = r.message;
const count = r.message ? r.message : current_count;
const $html = $(`<span>${current_count} of ${count}</span>`); const $html = $(`<span>${current_count} of ${count}</span>`);


$html.css({ $html.css({


Ladataan…
Peruuta
Tallenna