fix(stock): rollback before marking Stock Closing Entry failed (Postgres)

prepare_closing_stock_balance (background job) saves Stock Closing Balance rows + db_set status; on failure the except runs db_set('Failed')+log_error with no rollback, raising InFailedSqlTransaction on Postgres so the doc is never marked Failed and the job dies. Full frappe.db.rollback() before the handler's db_set. No-op on MariaDB.
This commit is contained in:
Mihir Kandoi
2026-06-29 22:45:19 +05:30
parent 44458b0ba5
commit 790560ebf8

View File

@@ -152,6 +152,7 @@ def prepare_closing_stock_balance(name):
doc.create_stock_closing_balance_entries()
doc.db_set("status", "Completed")
except Exception:
frappe.db.rollback()
doc.db_set("status", "Failed")
doc.log_error(title="Stock Closing Entry Failed")