V15 Multiple Variants Duplicate IntegrityError 1062

Hello everyone,
When I go to create multiple variants of over 10 variants I receive the following error below. So far we’ve had to create 7-8 variants at a time and it is very time consuming.

Let me know if any other information is needed.

Many thanks,

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 550, in db_insert
frappe.db.sql(
File “/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py”, line 234, in sql
self._cursor.execute(query, values)
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/pymysql/cursors.py”, line 153, in execute
result = self._query(query)
^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/pymysql/cursors.py”, line 322, in _query
conn.query(q)
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/pymysql/connections.py”, line 563, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/pymysql/connections.py”, line 825, in _read_query_result
result.read()
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/pymysql/connections.py”, line 1199, in read
first_packet = self.connection._read_packet()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/pymysql/connections.py”, line 775, in _read_packet
packet.raise_for_error()
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/pymysql/protocol.py”, line 219, in raise_for_error
err.raise_mysql_exception(self._data)
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/pymysql/err.py”, line 150, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.IntegrityError: (1062, “Duplicate entry ‘SRC-SRPB-615 V2R2-CN-XS-RCF’ for key ‘PRIMARY’”)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/rq/worker.py”, line 1428, in perform_job
rv = job.perform()
^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/rq/job.py”, line 1278, in perform
self._result = self._execute()
^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/env/lib/python3.11/site-packages/rq/job.py”, line 1315, in _execute
result = self.func(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py”, line 220, in execute_job
retval = method(**kwargs)
^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/controllers/item_variant.py”, line 252, in create_multiple_variants
variant.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 337, in save
return self._save(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 359, in _save
return self.insert()
^^^^^^^^^^^^^
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 302, in insert
self.db_insert(ignore_if_duplicate=ignore_if_duplicate)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 577, in db_insert
raise frappe.DuplicateEntryError(self.doctype, self.name, e)
frappe.exceptions.DuplicateEntryError: (‘Item’, ‘SRC-SRPB-615 V2R2-CN-XS-RCF’, IntegrityError(1062, “Duplicate entry ‘SRC-SRPB-615 V2R2-CN-XS-RCF’ for key ‘PRIMARY’”))

Hi @arcusag:

It working well … i tried with over 400 varants. If number of variants to create is over 10, job will be enqueued.

Check this:

Any way, seems one of you variants exist previously … can you delete it and try?
SRC-SRPB-615 V2R2-CN-XS-RCF

Hope this helps.

Having the same problem now… Did you fix it?