From bf7f0530e6cc14cb7722c767259c0c814fb1a8b8 Mon Sep 17 00:00:00 2001 From: noahjacob Date: Wed, 19 May 2021 13:53:22 +0530 Subject: [PATCH] fix: added error handling if entry already exists --- .../supplier_item_group/supplier_item_group.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/erpnext/buying/doctype/supplier_item_group/supplier_item_group.py b/erpnext/buying/doctype/supplier_item_group/supplier_item_group.py index 6fbeb372429..3a2e5d6dcef 100644 --- a/erpnext/buying/doctype/supplier_item_group/supplier_item_group.py +++ b/erpnext/buying/doctype/supplier_item_group/supplier_item_group.py @@ -3,8 +3,16 @@ # For license information, please see license.txt from __future__ import unicode_literals -# import frappe +import frappe +from frappe import _ from frappe.model.document import Document class SupplierItemGroup(Document): - pass + def validate(self): + exists = frappe.db.exists({ + 'doctype': 'Supplier Item Group', + 'supplier': self.supplier, + 'item_group': self.item_group + }) + if exists: + frappe.throw(_("Item Group has already been linked to this supplier.")) \ No newline at end of file