From d7a81affc22c35738ea79f019dea34d696892c1f Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Mon, 29 Jun 2026 22:37:59 +0530 Subject: [PATCH] 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. --- .../stock_and_account_value_comparison.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py b/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py index e295c0cb659..28308609f2f 100644 --- a/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py +++ b/erpnext/stock/report/stock_and_account_value_comparison/stock_and_account_value_comparison.py @@ -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)