[fixes] compare variants in lower case
This commit is contained in:
parent
bb7e499cbd
commit
47fd5e0ff0
@ -32,15 +32,16 @@ def validate_item_variant_attributes(item, args):
|
|||||||
attribute_values = {}
|
attribute_values = {}
|
||||||
for t in frappe.get_all("Item Attribute Value", fields=["parent", "attribute_value"],
|
for t in frappe.get_all("Item Attribute Value", fields=["parent", "attribute_value"],
|
||||||
filters={"parent": ["in", args.keys()]}):
|
filters={"parent": ["in", args.keys()]}):
|
||||||
(attribute_values.setdefault(t.parent, [])).append(t.attribute_value)
|
|
||||||
|
|
||||||
numeric_attributes = frappe._dict((t.attribute, t) for t in \
|
(attribute_values.setdefault(t.parent.lower(), [])).append(t.attribute_value)
|
||||||
|
|
||||||
|
numeric_attributes = frappe._dict((t.attribute.lower(), t) for t in \
|
||||||
frappe.db.sql("""select attribute, from_range, to_range, increment from `tabItem Variant Attribute`
|
frappe.db.sql("""select attribute, from_range, to_range, increment from `tabItem Variant Attribute`
|
||||||
where parent = %s and numeric_values=1""", (item), as_dict=1))
|
where parent = %s and numeric_values=1""", (item), as_dict=1))
|
||||||
|
|
||||||
for attribute, value in args.items():
|
for attribute, value in args.items():
|
||||||
if attribute in numeric_attributes:
|
if attribute.lower() in numeric_attributes:
|
||||||
numeric_attribute = numeric_attributes[attribute]
|
numeric_attribute = numeric_attributes[attribute.lower()]
|
||||||
|
|
||||||
from_range = numeric_attribute.from_range
|
from_range = numeric_attribute.from_range
|
||||||
to_range = numeric_attribute.to_range
|
to_range = numeric_attribute.to_range
|
||||||
@ -61,7 +62,7 @@ def validate_item_variant_attributes(item, args):
|
|||||||
frappe.throw(_("Value for Attribute {0} must be within the range of {1} to {2} in the increments of {3}")\
|
frappe.throw(_("Value for Attribute {0} must be within the range of {1} to {2} in the increments of {3}")\
|
||||||
.format(attribute, from_range, to_range, increment), InvalidItemAttributeValueError)
|
.format(attribute, from_range, to_range, increment), InvalidItemAttributeValueError)
|
||||||
|
|
||||||
elif value not in attribute_values.get(attribute, []):
|
elif value not in attribute_values.get(attribute.lower(), []):
|
||||||
frappe.throw(_("Value {0} for Attribute {1} does not exist in the list of valid Item Attribute Values").format(
|
frappe.throw(_("Value {0} for Attribute {1} does not exist in the list of valid Item Attribute Values").format(
|
||||||
value, attribute))
|
value, attribute))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user