From b760b9d9353b76467833673968d27b624b3561b9 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sun, 21 Jun 2026 15:29:36 +0530 Subject: [PATCH] test(stock): savepoint around expected duplicate barcode save (Postgres) The deliberate UniqueValidationError when re-adding a barcode aborts the transaction on Postgres, so the next frappe.get_doc() failed with InFailedSqlTransaction. Wrap the expected-failure save in a savepoint and roll back to it. No-op on MariaDB. --- erpnext/stock/doctype/item/test_item.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py index 4b6537edb87..6bb368fb123 100644 --- a/erpnext/stock/doctype/item/test_item.py +++ b/erpnext/stock/doctype/item/test_item.py @@ -751,7 +751,9 @@ class TestItem(ERPNextTestSuite): item_doc = frappe.get_doc("Item", item_code) new_barcode = item_doc.append("barcodes") new_barcode.update(barcode_properties_list[0]) + frappe.db.savepoint("dup_barcode") self.assertRaises(frappe.UniqueValidationError, item_doc.save) + frappe.db.rollback(save_point="dup_barcode") # preserve transaction in postgres # Add invalid barcode - should cause InvalidBarcode item_doc = frappe.get_doc("Item", item_code)