Merge pull request #33734 from frappe/mergify/bp/version-13-hotfix/pr-33619
fix: rewrite logic for duplicate check in Item Attribute (backport #33619)
This commit is contained in:
@@ -74,11 +74,10 @@ class ItemAttribute(Document):
|
|||||||
def validate_duplication(self):
|
def validate_duplication(self):
|
||||||
values, abbrs = [], []
|
values, abbrs = [], []
|
||||||
for d in self.item_attribute_values:
|
for d in self.item_attribute_values:
|
||||||
d.abbr = d.abbr.upper()
|
if d.attribute_value.lower() in map(str.lower, values):
|
||||||
if d.attribute_value in values:
|
frappe.throw(_("Attribute value: {0} must appear only once").format(d.attribute_value.title()))
|
||||||
frappe.throw(_("{0} must appear only once").format(d.attribute_value))
|
|
||||||
values.append(d.attribute_value)
|
values.append(d.attribute_value)
|
||||||
|
|
||||||
if d.abbr in abbrs:
|
if d.abbr.lower() in map(str.lower, abbrs):
|
||||||
frappe.throw(_("{0} must appear only once").format(d.abbr))
|
frappe.throw(_("Abbreviation: {0} must appear only once").format(d.abbr.title()))
|
||||||
abbrs.append(d.abbr)
|
abbrs.append(d.abbr)
|
||||||
|
|||||||
Reference in New Issue
Block a user