Wired! Not able to create any lead doc because of file mismatch error

Dear community,

I have tried for hours with no luck. I appreciate your support to fix this issue.

I have upgraded from V12 to V13. All is fine except for this issue (which I was thinking it is a bug in V13 but it seems a specific case in my setup).

When I create a new lead, click on Save, I always get this message:

Error: Document has been modified after you have opened it (2021-05-09 03:43:26.810242, 2021-05-09 03:43:26.840512). Please refresh to get the latest document.

I did try any possible fix, so far I tried the following:

  • Browser refresh
  • Bench clear-cache
  • Bench migrate
  • Bench update to most recent version
  • Deleted all Leads docs (tabLead has got empty).

Additional time-consuming tests, such as:

  • Bench reinstall (wiped out and started a fresh, :boom: then I am able to create leads without any issue. By the time I restore my old backup, the issue comes again).

  • Restored the database with empty Leads table; still the same.

  • Deleted all Contacts docs, oppurtunities docs, and quotations docs (those that might be linked to a Lead doc), with no luck.

Then, I follwed the Traceback, commented out the code in File ".../frappe/frappe/model/document.py", line 727, with no luck.

Any possible solutions?

Check below:

Traceback (most recent call last):
  File ".../apps/frappe/frappe/app.py", line 68, in application
    response = frappe.api.handle()
  File ".../apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File ".../apps/frappe/frappe/handler.py", line 31, in handle
    data = execute_cmd(cmd)
  File ".../apps/frappe/frappe/handler.py", line 67, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File ".../apps/frappe/frappe/__init__.py", line 1175, in call
    return fn(*args, **newargs)
  File ".../apps/frappe/frappe/desk/form/save.py", line 21, in savedocs
    doc.save()
  File ".../apps/frappe/frappe/model/document.py", line 284, in save
    return self._save(*args, **kwargs)
  File ".../apps/frappe/frappe/model/document.py", line 306, in _save
    self.insert()
  File ".../apps/frappe/frappe/model/document.py", line 258, in insert
    self.run_method("after_insert")
  File ".../apps/frappe/frappe/model/document.py", line 858, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File ".../apps/frappe/frappe/model/document.py", line 1147, in composer
    return composed(self, method, *args, **kwargs)
  File ".../apps/frappe/frappe/model/document.py", line 1130, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File ".../apps/frappe/frappe/model/document.py", line 852, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File ".../apps/erpnext/erpnext/crm/doctype/lead/lead.py", line 30, in after_insert
    self.update_links()
  File ".../apps/erpnext/erpnext/crm/doctype/lead/lead.py", line 200, in update_links
    self.contact_doc.save()
  File ".../apps/frappe/frappe/model/document.py", line 284, in save
    return self._save(*args, **kwargs)
  File ".../apps/frappe/frappe/model/document.py", line 313, in _save
    self.check_if_latest()
  File ".../apps/frappe/frappe/model/document.py", line 727, in check_if_latest
    raise_exception=frappe.TimestampMismatchError)
  File ".../apps/frappe/frappe/__init__.py", line 412, in msgprint
    _raise_exception()
  File ".../apps/frappe/frappe/__init__.py", line 366, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.TimestampMismatchError: Error: Document has been modified after you have opened it (2021-05-09 03:43:26.810242, 2021-05-09 03:43:26.840512). Please refresh to get the latest document.

I appreciate your support.

Thank you anyway !

I figured out the issue. It was because ERPNext V13 creates a contact for each Lead entry. My issue is because I did come form customization for the Contact doctype. Specifically, I have made the google sync as checked by default and set the google contacts value as the default value.

I think it should be considered as a bug.

3 Likes