fix(assets): savepoint per-entry depreciation posting (Postgres)

make_depreciation_entry posts a Journal Entry per schedule row in a loop; the except only stored the error, so the next row's je.save()/submit() ran on the Postgres-poisoned txn (InFailedSqlTransaction). Savepoint per iteration + rollback(save_point=) before storing the error; the final raise of the collected error is unchanged. No-op on MariaDB.
This commit is contained in:
Mihir Kandoi
2026-06-29 22:48:27 +05:30
parent 944eeb5921
commit 4feb9f9910

View File

@@ -187,6 +187,7 @@ def make_depreciation_entry(
for d in depr_schedule_doc.get("depreciation_schedule")[
(sch_start_idx or 0) : (sch_end_idx or len(depr_schedule_doc.get("depreciation_schedule")))
]:
frappe.db.savepoint("depr_entry")
try:
_make_journal_entry_for_depreciation(
depr_schedule_doc,
@@ -202,6 +203,7 @@ def make_depreciation_entry(
accounting_dimensions,
)
except Exception as e:
frappe.db.rollback(save_point="depr_entry")
depr_posting_error = e
asset.reload()