[error] Cannot delete department

I seem to be getting this error when trying to delete a department
I was using staging

ERPNext: v11.0.3-beta.10 () (staging)

then updated to

ERPNext: v11.0.3-beta.13 () (staging)

this seems to be fixed here

which was merged to staging 2 days ago

am I correct?

the error log:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 61, in application
    response = frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 56, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1007, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/client.py", line 237, in delete
    frappe.delete_doc(doctype, name, ignore_missing=False)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 752, in delete_doc
    ignore_permissions, flags, ignore_on_trash, ignore_missing)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/delete_doc.py", line 78, in delete_doc
    doc.run_method("on_trash")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 772, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1048, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1031, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 766, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/hr/doctype/department/department.py", line 38, in on_trash
    delete_events(self.doctype, self.name)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/utilities/transaction_base.py", line 150, in delete_events
    where ref_type=%s and ref_name=%s""", (ref_type, ref_name)), for_reload=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database.py", line 270, in sql_list
    return [r[0] for r in self.sql(query, values, debug=debug)]
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database.py", line 199, in sql
    self._cursor.execute(query, values)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py", line 328, in _query
    conn.query(q)
  File "/home/frappe/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/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 727, in _read_query_result
    result.read()
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 1066, in read
    first_packet = self.connection._read_packet()
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 683, in _read_packet
    packet.check_error()
  File "/home/frappe/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/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
InternalError: (1054, u"Unknown column 'ref_type' in 'where clause'")

Hey use “bench update --patch” else u can use “bench update --reset”

This might help you…!!!

I tried that yesterday with every single site, it updated but still the same issue.

I tried unit testing with a fresh installation on a staging production server

Ran 914 tests in 1765.039s

FAILED (failures=8, errors=54)

I’ve even tried in https://demo.erpnext.com and created a 30 day demo account too, same error :slight_smile:

Submitted an issue

1 Like

I am facing similar issue on Employee. Seems the merging is blocked on this one that is expected to resolve the problem.