fix(stock): savepoint repost loop in Stock and Account Value Comparison (Postgres)

The item/warehouse loop submits a Repost Item Valuation; a DuplicateEntryError poisons the Postgres transaction, so the next iteration's .submit() raises InFailedSqlTransaction. MariaDB continues. Savepoint per iteration + rollback(save_point=) on the caught duplicate (mirrors repost_item_valuation:782). No-op on MariaDB.
This commit is contained in:
Mihir Kandoi
2026-06-29 22:37:59 +05:30
parent 91dae91769
commit d7a81affc2

View File

@@ -202,6 +202,7 @@ def create_reposting_entries(rows: str | list, company: str):
for key, sle in item_wh.items():
item_code, warehouse = key
frappe.db.savepoint("repost_value_comparison")
try:
doc = frappe.get_doc(
{
@@ -219,7 +220,7 @@ def create_reposting_entries(rows: str | list, company: str):
entries.append(get_link_to_form("Repost Item Valuation", doc.name))
except frappe.DuplicateEntryError:
pass
frappe.db.rollback(save_point="repost_value_comparison")
if entries:
entries = ", ".join(entries)