diff --git a/erpnext/controllers/item_variant.py b/erpnext/controllers/item_variant.py index bf8c88cfb0..5e7ddbbd54 100644 --- a/erpnext/controllers/item_variant.py +++ b/erpnext/controllers/item_variant.py @@ -176,6 +176,14 @@ def create_variant(item, args): @frappe.whitelist() def enqueue_multiple_variant_creation(item, args): # There can be innumerable attribute combinations, enqueue + if isinstance(args, basestring): + variants = json.loads(args) + total_variants = 1 + for key in variants: + total_variants *= len(variants[key]) + if total_variants >= 600: + frappe.msgprint("Please do not create more than 500 items at a time", raise_exception=1) + return frappe.enqueue("erpnext.controllers.item_variant.create_multiple_variants", item=item, args=args, now=frappe.flags.in_test);