From d7441ec05144adb40e5c798912453a2032ecfd02 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 3 Jul 2015 19:07:23 +0530 Subject: [PATCH] [fix][patch] delete item variant attributes if no variants exists against that item --- erpnext/patches/v5_0/item_variants.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/patches/v5_0/item_variants.py b/erpnext/patches/v5_0/item_variants.py index 62e9ac9e1f..66300be671 100644 --- a/erpnext/patches/v5_0/item_variants.py +++ b/erpnext/patches/v5_0/item_variants.py @@ -11,6 +11,9 @@ def execute(): manage_variant.attributes = frappe.db.sql("select item_attribute as attribute, item_attribute_value as attribute_value \ from `tabItem Variant` where parent = %s", d.name, as_dict=1) if manage_variant.attributes: - manage_variant.generate_combinations() - manage_variant.create_variants() + if not frappe.get_list("Item", filters={"variant_of": d.name}, limit_page_length=1): + frappe.db.sql("delete from `tabItem Variant` where parent=%s", d.name) + else: + manage_variant.generate_combinations() + manage_variant.create_variants() frappe.delete_doc("DocType", "Item Variant") \ No newline at end of file