From bf9e25e42ec61d3b8f27911a6028f1cb966113ff Mon Sep 17 00:00:00 2001 From: kakde-sandeep Date: Sat, 1 Feb 2025 20:10:46 +0530 Subject: [PATCH 1/3] fix: #538 --- crm/api/doc.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crm/api/doc.py b/crm/api/doc.py index ad2cf99c..e0e68b05 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -372,9 +372,11 @@ def get_data( new_filters = filters.copy() new_filters.update({column_field: kc.get("name")}) - all_count = len( - frappe.get_list(doctype, filters=convert_filter_to_tuple(doctype, new_filters)) - ) + all_count = frappe.get_list( + doctype, + filters=convert_filter_to_tuple(doctype, new_filters), + fields="count(*) as count" + )[0].count kc["all_count"] = all_count kc["count"] = len(column_data) @@ -476,7 +478,9 @@ def get_data( "page_length_count": page_length_count, "is_default": is_default, "views": get_views(doctype), - "total_count": len(frappe.get_list(doctype, filters=filters)), + "total_count": frappe.get_list( + doctype, filters=filters, fields="count(*) as count" + )[0].count, "row_count": len(data), "form_script": get_form_script(doctype), "list_script": get_form_script(doctype, "List"), From e1feef71ff62bf483a977a9b60060a0407a4a381 Mon Sep 17 00:00:00 2001 From: kakde-sandeep Date: Sat, 1 Feb 2025 20:15:32 +0530 Subject: [PATCH 2/3] fix: indentation --- crm/api/doc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crm/api/doc.py b/crm/api/doc.py index e0e68b05..43b6ed52 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -479,8 +479,8 @@ def get_data( "is_default": is_default, "views": get_views(doctype), "total_count": frappe.get_list( - doctype, filters=filters, fields="count(*) as count" - )[0].count, + doctype, filters=filters, fields="count(*) as count" + )[0].count, "row_count": len(data), "form_script": get_form_script(doctype), "list_script": get_form_script(doctype, "List"), From 02e9c7bc75490f3308749a9d1478726e11cbdda4 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 26 Feb 2025 17:49:33 +0530 Subject: [PATCH 3/3] refactor: avoid use of reserved keywords --- crm/api/doc.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crm/api/doc.py b/crm/api/doc.py index 43b6ed52..9e12e998 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -375,8 +375,8 @@ def get_data( all_count = frappe.get_list( doctype, filters=convert_filter_to_tuple(doctype, new_filters), - fields="count(*) as count" - )[0].count + fields="count(*) as total_count" + )[0].total_count kc["all_count"] = all_count kc["count"] = len(column_data) @@ -479,8 +479,8 @@ def get_data( "is_default": is_default, "views": get_views(doctype), "total_count": frappe.get_list( - doctype, filters=filters, fields="count(*) as count" - )[0].count, + doctype, filters=filters, fields="count(*) as total_count" + )[0].total_count, "row_count": len(data), "form_script": get_form_script(doctype), "list_script": get_form_script(doctype, "List"),