From 4a572311bc836f835b8ec52fa5046abe3cd7d149 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Mon, 29 Jun 2026 22:38:01 +0530 Subject: [PATCH] fix(buying): insert default Supplier Scorecard records with ignore_if_duplicate (Postgres) make_default_records inserted Scorecard Variable/Standing rows in a loop and swallowed DuplicateEntryError (frappe.NameError). On Postgres the failed insert poisons the txn so the next iteration's insert raises InFailedSqlTransaction. insert(ignore_if_duplicate=True) emits ON CONFLICT DO NOTHING, never poisoning the txn. No-op on MariaDB. --- .../supplier_scorecard/supplier_scorecard.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py index 7a1db02082e..8c835a29912 100644 --- a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py +++ b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py @@ -405,16 +405,10 @@ def get_default_scorecard_standing(): def make_default_records(): install_variable_docs = get_default_scorecard_variables() for d in install_variable_docs: - try: - d["doctype"] = "Supplier Scorecard Variable" - frappe.get_doc(d).insert() - except frappe.NameError: - pass + d["doctype"] = "Supplier Scorecard Variable" + frappe.get_doc(d).insert(ignore_if_duplicate=True) install_standing_docs = get_default_scorecard_standing() for d in install_standing_docs: - try: - d["doctype"] = "Supplier Scorecard Standing" - frappe.get_doc(d).insert() - except frappe.NameError: - pass + d["doctype"] = "Supplier Scorecard Standing" + frappe.get_doc(d).insert(ignore_if_duplicate=True)