mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-18 19:07:55 +00:00
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:
@@ -304,6 +304,7 @@ def create_reposting_entries(rows: str | list, item_code: str | None = None, war
|
|||||||
for row in rows:
|
for row in rows:
|
||||||
row = frappe._dict(row)
|
row = frappe._dict(row)
|
||||||
|
|
||||||
|
frappe.db.savepoint("repost_invariant_check")
|
||||||
try:
|
try:
|
||||||
doc = frappe.get_doc(
|
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))
|
entries.append(get_link_to_form("Repost Item Valuation", doc.name))
|
||||||
except frappe.DuplicateEntryError:
|
except frappe.DuplicateEntryError:
|
||||||
|
frappe.db.rollback(save_point="repost_invariant_check")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if entries:
|
if entries:
|
||||||
|
|||||||
Reference in New Issue
Block a user