mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-20 03:47:11 +00:00
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:
@@ -47,6 +47,7 @@ def create_bank_entries(columns: str, data: str | list, bank_account: str):
|
|||||||
for key, value in header_map.items():
|
for key, value in header_map.items():
|
||||||
fields.update({key: d[int(value) - 1]})
|
fields.update({key: d[int(value) - 1]})
|
||||||
|
|
||||||
|
frappe.db.savepoint("bank_entry")
|
||||||
try:
|
try:
|
||||||
bank_transaction = frappe.get_doc({"doctype": "Bank Transaction"})
|
bank_transaction = frappe.get_doc({"doctype": "Bank Transaction"})
|
||||||
bank_transaction.update(fields)
|
bank_transaction.update(fields)
|
||||||
@@ -56,6 +57,7 @@ def create_bank_entries(columns: str, data: str | list, bank_account: str):
|
|||||||
bank_transaction.submit()
|
bank_transaction.submit()
|
||||||
success += 1
|
success += 1
|
||||||
except Exception:
|
except Exception:
|
||||||
|
frappe.db.rollback(save_point="bank_entry")
|
||||||
bank_transaction.log_error("Bank entry creation failed")
|
bank_transaction.log_error("Bank entry creation failed")
|
||||||
errors += 1
|
errors += 1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user