Help! Error when loading Stock Entry page

Dear Developers,

Please help. I’m having a problem when my user is trying to load Stock Entry.

I’ve customized the Stock Entry and Stock Entry Detail so that “Amount” and “rate” requires permission level 1.

But now, it seems when user is trying to load the stock entry module, the following error appears:

Traceback (most recent call last):
File “/home/jetplane/frappe-bench/apps/frappe/frappe/”, line 55, in application
response = frappe.handler.handle()
File “/home/jetplane/frappe-bench/apps/frappe/frappe/”, line 19, in handle
File “/home/jetplane/frappe-bench/apps/frappe/frappe/”, line 36, in execute_cmd
ret =, **frappe.form_dict)
File “/home/jetplane/frappe-bench/apps/frappe/frappe/”, line 879, in call
return fn(*args, **newargs)
File “/home/jetplane/frappe-bench/apps/frappe/frappe/desk/”, line 16, in get
data = compress(execute(**args))
File “/home/jetplane/frappe-bench/apps/frappe/frappe/desk/”, line 21, in execute
return DatabaseQuery(doctype).execute(*args, **kwargs)
File “/home/jetplane/frappe-bench/apps/frappe/frappe/model/”, line 79, in execute
result = self.build_and_run()
File “/home/jetplane/frappe-bench/apps/frappe/frappe/model/”, line 103, in build_and_run
return frappe.db.sql(query, as_dict=not self.as_list, debug=self.debug, update=self.update)
File “/home/jetplane/frappe-bench/apps/frappe/frappe/”, line 148, in sql
File “/home/jetplane/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/jetplane/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1054, “Unknown column ‘tabStock Entry.item_code’ in ‘order clause’”)

please help… thanks a million!

If this is a custom report, you will have to share the query / script

haha… I solved it.

I don’t know how “item_code” got selected in the SORT button, but after changing it, it is ok.