Merge pull request #4206 from neilLasrado/variant

Prevent Template Item from going into infinite loop while saving
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 9c4ccdc..7c0d0e0 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -412,10 +412,11 @@
 			if not template_item.show_in_website:
 				template_item.show_in_website = 1
 				template_item.flags.ignore_permissions = True
+				template_item.flags.dont_update_variants = True
 				template_item.save()
 
 	def update_variants(self):
-		if self.has_variants:
+		if self.has_variants and not self.flags.dont_update_variants:
 			updated = []
 			variants = frappe.db.get_all("Item", fields=["item_code"], filters={"variant_of": self.name })
 			for d in variants: