[fix] Disable atrribute table in variant item record
diff --git a/erpnext/controllers/item_variant.py b/erpnext/controllers/item_variant.py
index 5890b5d..a8f69ca 100644
--- a/erpnext/controllers/item_variant.py
+++ b/erpnext/controllers/item_variant.py
@@ -12,7 +12,7 @@
class ItemTemplateCannotHaveStock(frappe.ValidationError): pass
@frappe.whitelist()
-def get_variant(item, args):
+def get_variant(variant, template, args):
"""Validates Attributes and their Values, then looks for an exactly matching Item Variant
:param item: Template Item
@@ -24,9 +24,9 @@
if not args:
frappe.throw(_("Please specify at least one attribute in the Attributes table"))
- validate_item_variant_attributes(item, args)
+ validate_item_variant_attributes(template, args)
- return find_variant(item, args)
+ return find_variant(variant, template, args)
def validate_item_variant_attributes(item, args):
attribute_values = {}
@@ -65,7 +65,7 @@
frappe.throw(_("Value {0} for Attribute {1} does not exist in the list of valid Item Attribute Values").format(
value, attribute))
-def find_variant(item, args):
+def find_variant(variant_item_code, template, args):
conditions = ["""(iv_attribute.attribute="{0}" and iv_attribute.attribute_value="{1}")"""\
.format(frappe.db.escape(key), frappe.db.escape(cstr(value))) for key, value in args.items()]
@@ -79,8 +79,8 @@
where variant_of=%s and exists (
select name from `tabItem Variant Attribute` iv_attribute
where iv_attribute.parent=item.name
- and ({conditions})
- )""".format(conditions=conditions), item)
+ and ({conditions}) and parent != %s
+ )""".format(conditions=conditions), (template, variant_item_code))
for variant in possible_variants:
variant = frappe.get_doc("Item", variant)