Explorar el Código

count issue if child table exists in filter fix

version-14
Zlash65 hace 7 años
padre
commit
7d2e30d529
Se han modificado 2 ficheros con 19 adiciones y 5 borrados
  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 Ver fichero

@@ -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

+ 2
- 2
frappe/public/js/frappe/list/list_renderer.js Ver fichero

@@ -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({


Cargando…
Cancelar
Guardar