Strange Error while accessing Doctype - tabSales Invoice does not exist? - only fix is to restart bench

Hi,

I have a multitenant environment in which one of the site just has Frappe and a Custom app installed ( No ERPNext whatsoever). Still today when I tried to access one of the Doctype’s list, it gave me a bizarre error “Table ‘2f041c57b7cf613b.tabSales Invoice’ doesn’t exist” This is the second time I have gotten this error. Doing a bench start resolved my problem. Worth to mention that I have ERPNext installed in other sites. Have any else faced this issue ? Any bug with multitenancy ?

Thanks,
Palash

Could you share complete error log for Sales Invoice doesn’t exist error? Perhaps there is a script in the custom app calling Sales Invoice?

I only have part of the error log that too in the screenshot. I dont know why but I deleted the logs from Error Log list doctype. Let me check in the error log file once and update.

But strange thing is this particular site does not have ERPNext installed at all. So now my doubt is there a parent (Frappe framework level) level script/custom script which runs for all the site?

Traceback (most recent call last):
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/app.py”, line 62, in application
response = frappe.handler.handle()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/handler.py”, line 22, in handle
data = execute_cmd(cmd)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/handler.py”, line 53, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 939, in call
return fn(*args, **newargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/desk/form/load.py”, line 33, in getdoc
run_onload(doc)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/desk/form/load.py”, line 202, in run_onload
doc.run_method(“onload”)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 757, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 1026, in composer
return composed(self, method, *args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 1009, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 751, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/ubuntu/frappe-bench/apps/erpnext/erpnext/setup/doctype/company/company.py”, line 18, in onload
self.get(“__onload”)[“transactions_exist”] = self.check_if_transactions_exist()
File “/home/ubuntu/frappe-bench/apps/erpnext/erpnext/setup/doctype/company/company.py”, line 25, in check_if_transactions_exist
limit 1"“” % (doctype, “%s”), self.name):
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/database.py”, line 166, in sql
self._cursor.execute(query, values)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py”, line 170, in execute
result = self._query(query)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py”, line 328, in _query
conn.query(q)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 516, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 727, in _read_query_result
result.read()
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 1066, in read
first_packet = self.connection._read_packet()
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 683, in _read_packet
packet.check_error()
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/protocol.py”, line 220, in check_error
err.raise_mysql_exception(self._data)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/err.py”, line 109, in raise_mysql_exception
raise errorclass(errno, errval)
ProgrammingError: (1146, u"Table ‘2f041c57b7cf613b.tabSales Invoice’ doesn’t exist")

Here is the complete error from web.log file. And there is no script in the custom app at least I haven’t created one.