Prevent creation of more than 500 item variants (#14790)
This commit is contained in:
parent
aa62a62bb0
commit
935f4a474b
@ -176,6 +176,14 @@ def create_variant(item, args):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def enqueue_multiple_variant_creation(item, args):
|
def enqueue_multiple_variant_creation(item, args):
|
||||||
# There can be innumerable attribute combinations, enqueue
|
# 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",
|
frappe.enqueue("erpnext.controllers.item_variant.create_multiple_variants",
|
||||||
item=item, args=args, now=frappe.flags.in_test);
|
item=item, args=args, now=frappe.flags.in_test);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user