From 3a2ddf887f0a28ef97d66a79fe02c8eaf7ff8654 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Fri, 28 Mar 2025 13:10:12 +0530 Subject: [PATCH] fix: for deadlock issue keep status as In Progress --- .../repost_item_valuation.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py index 80391199c2..47a30447b6 100644 --- a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py +++ b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py @@ -269,7 +269,7 @@ def repost(doc): status = "Failed" # If failed because of timeout, set status to In Progress - if traceback and "timeout" in traceback.lower(): + if traceback and ("timeout" in traceback.lower() or "Deadlock found" in traceback): status = "In Progress" if traceback: @@ -284,13 +284,14 @@ def repost(doc): }, ) - outgoing_email_account = frappe.get_cached_value( - "Email Account", {"default_outgoing": 1, "enable_outgoing": 1}, "name" - ) + if status == "Failed": + outgoing_email_account = frappe.get_cached_value( + "Email Account", {"default_outgoing": 1, "enable_outgoing": 1}, "name" + ) - if outgoing_email_account and not isinstance(e, RecoverableErrors): - notify_error_to_stock_managers(doc, message) - doc.set_status("Failed") + if outgoing_email_account and not isinstance(e, RecoverableErrors): + notify_error_to_stock_managers(doc, message) + doc.set_status("Failed") finally: if not frappe.flags.in_test: frappe.db.commit() -- GitLab