fix(accounts): savepoint per-row bank entry in Bank Transaction upload (Postgres)

create_bank_entries loops rows inserting+submitting a Bank Transaction; on failure the except calls bank_transaction.log_error (INSERT) with no rollback, raising InFailedSqlTransaction on Postgres, and the next row runs in the poisoned txn. Savepoint per row + rollback(save_point=) before log_error. No-op on MariaDB.
This commit is contained in:
Mihir Kandoi
2026-06-29 22:38:02 +05:30
parent 4a572311bc
commit c97eac34bf

View File

@@ -47,6 +47,7 @@ def create_bank_entries(columns: str, data: str | list, bank_account: str):
for key, value in header_map.items():
fields.update({key: d[int(value) - 1]})
frappe.db.savepoint("bank_entry")
try:
bank_transaction = frappe.get_doc({"doctype": "Bank Transaction"})
bank_transaction.update(fields)
@@ -56,6 +57,7 @@ def create_bank_entries(columns: str, data: str | list, bank_account: str):
bank_transaction.submit()
success += 1
except Exception:
frappe.db.rollback(save_point="bank_entry")
bank_transaction.log_error("Bank entry creation failed")
errors += 1