fix(stock): savepoint repost loop in Stock Ledger Invariant Check (Postgres)

Same shape: the rows loop submits a Repost Item Valuation; a caught DuplicateEntryError poisons the Postgres txn so the next iteration's submit raises InFailedSqlTransaction. Savepoint + rollback(save_point=) before continue. No-op on MariaDB.
This commit is contained in:
Mihir Kandoi
2026-06-29 22:38:00 +05:30
parent d7a81affc2
commit 1dde2b5f1e

View File

@@ -304,6 +304,7 @@ def create_reposting_entries(rows: str | list, item_code: str | None = None, war
for row in rows:
row = frappe._dict(row)
frappe.db.savepoint("repost_invariant_check")
try:
doc = frappe.get_doc(
{
@@ -320,6 +321,7 @@ def create_reposting_entries(rows: str | list, item_code: str | None = None, war
entries.append(get_link_to_form("Repost Item Valuation", doc.name))
except frappe.DuplicateEntryError:
frappe.db.rollback(save_point="repost_invariant_check")
continue
if entries: