From 41f11eca7221e8534f8ad4cfd660057de276e484 Mon Sep 17 00:00:00 2001 From: Marica Date: Fri, 17 Sep 2021 10:27:29 +0530 Subject: [PATCH] fix: Remove duplicates from customer_code field (#27555) --- erpnext/stock/doctype/item/item.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index 86737f29b0ca..768e5eae2daa 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -563,8 +563,12 @@ def check_for_active_boms(self): _("Default BOM ({0}) must be active for this item or its template").format(bom_item)) def fill_customer_code(self): - """ Append all the customer codes and insert into "customer_code" field of item table """ - self.customer_code = ','.join(d.ref_code for d in self.get("customer_items", [])) + """ + Append all the customer codes and insert into "customer_code" field of item table. + Used to search Item by customer code. + """ + customer_codes = set(d.ref_code for d in self.get("customer_items", [])) + self.customer_code = ','.join(customer_codes) def check_item_tax(self): """Check whether Tax Rate is not entered twice for same Tax Type"""