Merge pull request #23596 from marination/item-attribute-validation-on-non-template-item
fix: Perform Item Attribute Value Validation on Variants Only
This commit is contained in:
commit
80519b1098
@ -29,9 +29,18 @@ class ItemAttribute(Document):
|
|||||||
'''Validate that if there are existing items with attributes, they are valid'''
|
'''Validate that if there are existing items with attributes, they are valid'''
|
||||||
attributes_list = [d.attribute_value for d in self.item_attribute_values]
|
attributes_list = [d.attribute_value for d in self.item_attribute_values]
|
||||||
|
|
||||||
for item in frappe.db.sql('''select i.name, iva.attribute_value as value
|
# Get Item Variant Attribute details of variant items
|
||||||
from `tabItem Variant Attribute` iva, `tabItem` i where iva.attribute = %s
|
items = frappe.db.sql("""
|
||||||
and iva.parent = i.name and i.has_variants = 0''', self.name, as_dict=1):
|
select
|
||||||
|
i.name, iva.attribute_value as value
|
||||||
|
from
|
||||||
|
`tabItem Variant Attribute` iva, `tabItem` i
|
||||||
|
where
|
||||||
|
iva.attribute = %(attribute)s
|
||||||
|
and iva.parent = i.name and
|
||||||
|
i.variant_of is not null and i.variant_of != ''""", {"attribute" : self.name}, as_dict=1)
|
||||||
|
|
||||||
|
for item in items:
|
||||||
if self.numeric_values:
|
if self.numeric_values:
|
||||||
validate_is_incremental(self, self.name, item.value, item.name)
|
validate_is_incremental(self, self.name, item.value, item.name)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user