From 3cef94e2edab9abf5d27b687f86b98b688ce3faa Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 11:05:24 +0530 Subject: [PATCH] fix: validate last_gl_update exists before comparing (backport #46464) (#46468) fix: validate last_gl_update exists before comparing (#46464) (cherry picked from commit 0a5ca0c35f92a52a5236d8fd08fb4a107585c2e0) Co-authored-by: Dany Robert --- erpnext/accounts/doctype/account/account.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index 2f1ddb2f96f..3e026e104ad 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -607,6 +607,7 @@ def _ensure_idle_system(): if frappe.flags.in_test: return + last_gl_update = None try: # We also lock inserts to GL entry table with for_update here. last_gl_update = frappe.db.get_value("GL Entry", {}, "modified", for_update=True, wait=False) @@ -614,6 +615,9 @@ def _ensure_idle_system(): # wait=False fails immediately if there's an active transaction. last_gl_update = add_to_date(None, seconds=-1) + if not last_gl_update: + return + if last_gl_update > add_to_date(None, minutes=-5): frappe.throw( _(