fix: defer access log inserts in read only mod

This commit is contained in:
Ankush Menat 2023-07-03 13:34:44 +05:30
parent 8e329a92a3
commit 00e5dabef1

View file

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