예제 #1
0
    def validate_exising_items(self):
        '''Validate that if there are existing items with attributes, they are valid'''
        attributes_list = [
            d.attribute_value for d in self.item_attribute_values
        ]

        # Get Item Variant Attribute details of variant items
        items = frappe.db.sql("""
			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:
                validate_is_incremental(self, self.name, item.value, item.name)
            else:
                validate_item_attribute_value(attributes_list,
                                              self.name,
                                              item.value,
                                              item.name,
                                              from_variant=False)
예제 #2
0
	def validate_exising_items(self):
		'''Validate that if there are existing items with attributes, they are valid'''
		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
			from `tabItem Variant Attribute` iva, `tabItem` i where iva.attribute = %s
			and iva.parent = i.name and i.has_variants = 0''', self.name, as_dict=1):
			if self.numeric_values:
				validate_is_incremental(self, self.name, item.value, item.name)
			else:
				validate_item_attribute_value(attributes_list, self.name, item.value, item.name)