Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug V11] Cannot delete department #15846

Closed
Yemeni opened this issue Oct 28, 2018 · 4 comments
Closed

[bug V11] Cannot delete department #15846

Yemeni opened this issue Oct 28, 2018 · 4 comments

Comments

@Yemeni
Copy link

Yemeni commented Oct 28, 2018

Description:
When I try to delete department I get an error.

Steps to reproduce:

  1. make new erpnext installation
  2. complete the setup
  3. go to
    https://site.example:8000/desk#List/Department/List
    or https://site.example:80/desk#List/Department/List
  4. create a department
  5. delete the department

the bug happens (also with an Administrator account)

tried in version:
ERPNext: v11.0.3-beta.10 () (staging)
ERPNext: v11.0.3-beta.12 () (staging)
ERPNext: v11.0.3-beta.13 () (staging)
ERPNext: v11.0.3-beta.15 () (staging)

on my Linode Ubuntu 16 LTS server
and on https://demo.erpnext.com

Related article
https://discuss.erpnext.com/t/error-cannot-delete-department

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'")

A screenshot of the bug on the official erpnext demo
image

@vishdha
Copy link
Contributor

vishdha commented Oct 29, 2018

there is no column ref_type and ref_name in Event Doctype. That's why cause this error. you can change
frappe.db.sql_list("""select name from tabEvent
where parent=%s and name=%s""" with parent and name.
anyway, no event created on this trigger.

@Yemeni
Copy link
Author

Yemeni commented Oct 29, 2018

u mean here in line 148 - 150?
https://github.com/frappe/erpnext/blob/staging/erpnext/utilities/transaction_base.py
is it gonna be a fix? do it locally or make a pull request? will I be able to update to next version successfully if I modify the code? because in v10 it's working fine and there was ref_type in sql?

@vishdha
Copy link
Contributor

vishdha commented Oct 29, 2018

for pull request, you need to add patch for a missing field in Event Doctype like ref_type and reference_name

@Yemeni
Copy link
Author

Yemeni commented Oct 29, 2018

Just that file? there are other files with ref_type,

"ref_type": self.doctype,
"ref_name": self.name

in
https://github.com/frappe/erpnext/blob/staging/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants