From 974e12c8378c729647965bdfd65f52f89154609b Mon Sep 17 00:00:00 2001 From: unknown <57280279+SvbZ3r0@users.noreply.github.com> Date: Thu, 12 Jan 2023 07:44:57 +0530 Subject: [PATCH 1/2] fix: rewrite logic for duplicate check in Item Attribute Previously, Item Attribute values were not checked for case-insensitive duplicates, and Item tttribute abbreviations were forced to be uppercase. This commit fixes both problems. --- .../stock/doctype/item_attribute/item_attribute.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/erpnext/stock/doctype/item_attribute/item_attribute.py b/erpnext/stock/doctype/item_attribute/item_attribute.py index 391ff06918..018d5257e1 100644 --- a/erpnext/stock/doctype/item_attribute/item_attribute.py +++ b/erpnext/stock/doctype/item_attribute/item_attribute.py @@ -74,11 +74,12 @@ class ItemAttribute(Document): def validate_duplication(self): values, abbrs = [], [] for d in self.item_attribute_values: - d.abbr = d.abbr.upper() - if d.attribute_value in values: - frappe.throw(_("{0} must appear only once").format(d.attribute_value)) + if d.attribute_value.lower() in map(str.lower, values): + frappe.throw( + _("Attribute value: {0} must appear only once").format(d.attribute_value.title())) values.append(d.attribute_value) - if d.abbr in abbrs: - frappe.throw(_("{0} must appear only once").format(d.abbr)) + if d.abbr.lower() in map(str.lower, abbrs): + frappe.throw( + _("Abbreviation: {0} must appear only once").format(d.abbr.title())) abbrs.append(d.abbr) From 2ca4d3fb71587bae26f23f2c748884cc1b27b744 Mon Sep 17 00:00:00 2001 From: unknown <57280279+SvbZ3r0@users.noreply.github.com> Date: Thu, 12 Jan 2023 20:53:12 +0530 Subject: [PATCH 2/2] fix: linting --- erpnext/stock/doctype/item_attribute/item_attribute.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/doctype/item_attribute/item_attribute.py b/erpnext/stock/doctype/item_attribute/item_attribute.py index 018d5257e1..ac4c313e28 100644 --- a/erpnext/stock/doctype/item_attribute/item_attribute.py +++ b/erpnext/stock/doctype/item_attribute/item_attribute.py @@ -75,11 +75,9 @@ class ItemAttribute(Document): values, abbrs = [], [] for d in self.item_attribute_values: if d.attribute_value.lower() in map(str.lower, values): - frappe.throw( - _("Attribute value: {0} must appear only once").format(d.attribute_value.title())) + frappe.throw(_("Attribute value: {0} must appear only once").format(d.attribute_value.title())) values.append(d.attribute_value) if d.abbr.lower() in map(str.lower, abbrs): - frappe.throw( - _("Abbreviation: {0} must appear only once").format(d.abbr.title())) + frappe.throw(_("Abbreviation: {0} must appear only once").format(d.abbr.title())) abbrs.append(d.abbr)