From 00e5dabef144fb916c9daec4591e47302d39d796 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Mon, 3 Jul 2023 13:34:44 +0530 Subject: [PATCH] fix: defer access log inserts in read only mod --- frappe/core/doctype/access_log/access_log.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/frappe/core/doctype/access_log/access_log.py b/frappe/core/doctype/access_log/access_log.py index c194f5d603..5a6b304e9e 100644 --- a/frappe/core/doctype/access_log/access_log.py +++ b/frappe/core/doctype/access_log/access_log.py @@ -59,7 +59,7 @@ def _make_access_log( user = frappe.session.user in_request = frappe.request and frappe.request.method == "GET" - frappe.get_doc( + access_log = frappe.get_doc( { "doctype": "Access Log", "user": user, @@ -72,7 +72,12 @@ def _make_access_log( "filters": cstr(filters) or None, "columns": columns, } - ).db_insert() + ) + + if frappe.flags.read_only: + access_log.deferred_insert() + else: + access_log.db_insert() # `frappe.db.commit` added because insert doesnt `commit` when called in GET requests like `printview` # dont commit in test mode. It must be tempting to put this block along with the in_request in the