[BUG] Cannot create New document

I’m having an issue with my production server where I cannot create new Material Request documents. I had this issue previously with Supplier Quotations and Purchase Orders. I think the issue started when we transitioned to v7.

The issue is that there is already a document with the name already assigned. I’m not sure how Frappe picks a new document name, but it seems to be grabbing a bad one.

The way I’ve resolved it in the past is by cancelling and deleting the conflicting document, then recreating it. For some of the documents, I’ve had to cancel multiple ones.

With the material requests, they are linked to several documents so I can’t easily do this.

Any suggestions?

Here is a video showing the issue:


Traceback (most recent call last):
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 22, in savedocs
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 242, in save
return self._save(*args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 259, in _save
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 223, in insert
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 284, in db_insert
), d.values())
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/database.py”, line 137, in sql
self._cursor.execute(query, values)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
DuplicateEntryError: (u’Material Request’, u’MREQ-01769’, IntegrityError(1062, “Duplicate entry ‘MREQ-01769’ for key ‘PRIMARY’”))

@Ben_Cornwell_Mott no one has reported this yet. How do we replicate this?

Have you changed the series manually? Or are you pushing material requests at a high frequency via the API?

I don’t think I’ve done either. I have pushed a high frequency of items and BOMs through the API, but not material requests. I haven’t done any manual database modifications.

I’m really not sure how to replicate it. It hasn’t resolved itself through any bench updates.

After looking through the code, it looks like my current from tabSeries isn’t up to date in my database. Not sure how that would have happened. I’ve been able to fix the problem by doing the following:

in frappe-bench/

bench execute --args "'MREQ-',5" frappe.model.naming.getseries

I tried running it in the console (or doing a frappe.db.sql command) but as soon as I exited the console it would revert back. I’m not sure why that would happen.

Seems very strange. No one has reported it yet.

Hi there,

I had the same problem, but with Lead and Opportunities, so the client almost couldn’t work. It happened after upgrading to V7.

I solved the problem by updating the sequence values of the series.

Kind regards,