Error While accessing Leave Type Page

App Versions

{
“erpnext”: “10.1.35”,
“frappe”: “10.1.34”
}

Route

List/Leave Type/List

Error Report

Traceback (most recent call last):
File “/opt/bench/erpnext/apps/frappe/frappe/app.py”, line 62, in application
response = frappe.handler.handle()
File “/opt/bench/erpnext/apps/frappe/frappe/handler.py”, line 22, in handle
data = execute_cmd(cmd)
File “/opt/bench/erpnext/apps/frappe/frappe/handler.py”, line 53, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/opt/bench/erpnext/apps/frappe/frappe/init.py”, line 942, in call
return fn(*args, **newargs)
File “/opt/bench/erpnext/apps/frappe/frappe/desk/reportview.py”, line 21, in get
data = compress(execute(**args), args = args)
File “/opt/bench/erpnext/apps/frappe/frappe/desk/reportview.py”, line 26, in execute
return DatabaseQuery(doctype).execute(*args, **kwargs)
File “/opt/bench/erpnext/apps/frappe/frappe/model/db_query.py”, line 87, in execute
result = self.build_and_run()
File “/opt/bench/erpnext/apps/frappe/frappe/model/db_query.py”, line 111, in build_and_run
return frappe.db.sql(query, as_dict=not self.as_list, debug=self.debug, update=self.update)
File “/opt/bench/erpnext/apps/frappe/frappe/database.py”, line 209, in sql
self._cursor.execute(query)
File “/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/cursors.py”, line 165, in execute
result = self._query(query)
File “/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/cursors.py”, line 321, in _query
conn.query(q)
File “/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/connections.py”, line 860, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/connections.py”, line 1061, in _read_query_result
result.read()
File “/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/connections.py”, line 1349, in read
first_packet = self.connection._read_packet()
File “/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/connections.py”, line 1018, in _read_packet
packet.check_error()
File “/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/connections.py”, line 384, in check_error
err.raise_mysql_exception(self._data)
File “/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/err.py”, line 107, in raise_mysql_exception
raise errorclass(errno, errval)
InternalError: (1054, u"Unknown column ‘tabLeave Type.max_days_allowed’ in ‘field list’")

Request Data

{
“type”: “GET”,
“args”: {
“doctype”: “Leave Type”,
“fields”: “["tabLeave Type.name","tabLeave Type.owner","tabLeave Type.creation","tabLeave Type.modified","tabLeave Type.modified_by","tabLeave Type._user_tags","tabLeave Type._comments","tabLeave Type._assign","tabLeave Type._liked_by","tabLeave Type.docstatus","tabLeave Type.parent","tabLeave Type.parenttype","tabLeave Type.parentfield","tabLeave Type.idx","tabLeave Type.leave_type_name","tabLeave Type.max_days_allowed","tabLeave Type.is_carry_forward","tabLeave Type.is_encash"]”,
“filters”: “[]”,
“order_by”: “tabLeave Type.modified desc”,
“start”: 0,
“page_length”: 20,
“with_comment_count”: true,
“cmd”: “frappe.desk.reportview.get”
},
“freeze”: false,
“freeze_message”: “Loading…”,
“url”: “/”
}

Response JSON

{}

Which branch are you using? Is it in develop branch? Please raise an issue in github.

I am using sudo bench setup production bench (Production Branch)

Hello @vijaypatel

Take latest pull from ERPNext and frappe branch and performed below command before create new
site.

bench migrate
bench clear-cache
bench build
bench setup requirements

Thanks.

To Elaborate on this:
Earlier i had an issue with leave application

App Versions

{
	"erpnext": "10.1.35",
	"frappe": "10.1.34"
}

Route

Form/Leave Application/New Leave Application 1

Error Report

Traceback (most recent call last):
  File "/opt/bench/erpnext/apps/frappe/frappe/desk/form/save.py", line 22, in savedocs
    doc.save()
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 260, in save
    return self._save(*args, **kwargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 283, in _save
    self.insert()
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 222, in insert
    self.run_before_save_methods()
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 869, in run_before_save_methods
    self.run_method("validate")
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 765, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 1040, in composer
    return composed(self, method, *args, **kwargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 1023, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 759, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/opt/bench/erpnext/apps/erpnext/erpnext/hr/doctype/leave_application/leave_application.py", line 30, in validate
    self.validate_max_days()
  File "/opt/bench/erpnext/apps/erpnext/erpnext/hr/doctype/leave_application/leave_application.py", line 255, in validate_max_days
    max_days = frappe.db.get_value("Leave Type", self.leave_type, "max_continuous_days_allowed")
  File "/opt/bench/erpnext/apps/frappe/frappe/database.py", line 482, in get_value
    order_by, cache=cache)
  File "/opt/bench/erpnext/apps/frappe/frappe/database.py", line 526, in get_values
    out = self._get_values_from_table(fields, filters, doctype, as_dict, debug, order_by, update)
  File "/opt/bench/erpnext/apps/frappe/frappe/database.py", line 666, in _get_values_from_table
    as_dict=as_dict, debug=debug, update=update)
  File "/opt/bench/erpnext/apps/frappe/frappe/database.py", line 199, in sql
    self._cursor.execute(query, values)
  File "/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/cursors.py", line 165, in execute
    result = self._query(query)
  File "/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/cursors.py", line 321, in _query
    conn.query(q)
  File "/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/connections.py", line 860, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/connections.py", line 1061, in _read_query_result
    result.read()
  File "/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/connections.py", line 1349, in read
    first_packet = self.connection._read_packet()
  File "/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/connections.py", line 1018, in _read_packet
    packet.check_error()
  File "/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/connections.py", line 384, in check_error
    err.raise_mysql_exception(self._data)
  File "/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/err.py", line 107, in raise_mysql_exception
    raise errorclass(errno, errval)
InternalError: (1054, u"Unknown column 'max_continuous_days_allowed' in 'field list'")

Traceback (most recent call last):
  File "/opt/bench/erpnext/apps/frappe/frappe/app.py", line 62, in application
    response = frappe.handler.handle()
  File "/opt/bench/erpnext/apps/frappe/frappe/handler.py", line 22, in handle
    data = execute_cmd(cmd)
  File "/opt/bench/erpnext/apps/frappe/frappe/handler.py", line 53, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/opt/bench/erpnext/apps/frappe/frappe/__init__.py", line 942, in call
    return fn(*args, **newargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/desk/form/save.py", line 22, in savedocs
    doc.save()
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 260, in save
    return self._save(*args, **kwargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 283, in _save
    self.insert()
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 222, in insert
    self.run_before_save_methods()
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 869, in run_before_save_methods
    self.run_method("validate")
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 765, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 1040, in composer
    return composed(self, method, *args, **kwargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 1023, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 759, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/opt/bench/erpnext/apps/erpnext/erpnext/hr/doctype/leave_application/leave_application.py", line 30, in validate
    self.validate_max_days()
  File "/opt/bench/erpnext/apps/erpnext/erpnext/hr/doctype/leave_application/leave_application.py", line 255, in validate_max_days
    max_days = frappe.db.get_value("Leave Type", self.leave_type, "max_continuous_days_allowed")
  File "/opt/bench/erpnext/apps/frappe/frappe/database.py", line 482, in get_value
    order_by, cache=cache)
  File "/opt/bench/erpnext/apps/frappe/frappe/database.py", line 526, in get_values
    out = self._get_values_from_table(fields, filters, doctype, as_dict, debug, order_by, update)
  File "/opt/bench/erpnext/apps/frappe/frappe/database.py", line 666, in _get_values_from_table
    as_dict=as_dict, debug=debug, update=update)
  File "/opt/bench/erpnext/apps/frappe/frappe/database.py", line 199, in sql
    self._cursor.execute(query, values)
  File "/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/cursors.py", line 165, in execute
    result = self._query(query)
  File "/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/cursors.py", line 321, in _query
    conn.query(q)
  File "/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/connections.py", line 860, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/connections.py", line 1061, in _read_query_result
    result.read()
  File "/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/connections.py", line 1349, in read
    first_packet = self.connection._read_packet()
  File "/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/connections.py", line 1018, in _read_packet
    packet.check_error()
  File "/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/connections.py", line 384, in check_error
    err.raise_mysql_exception(self._data)
  File "/opt/bench/erpnext/env/lib/python2.7/site-packages/pymysql/err.py", line 107, in raise_mysql_exception
    raise errorclass(errno, errval)
InternalError: (1054, u"Unknown column 'max_continuous_days_allowed' in 'field list'")
</lambda></lambda>

Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"docstatus\":0,\"doctype\":\"Leave Application\",\"name\":\"New Leave Application 1\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"vijay@tecobytes.com\",\"naming_series\":\"LAP/\",\"status\":\"Open\",\"posting_date\":\"2018-05-29\",\"follow_via_email\":1,\"company\":\"TecoBytes Solutions Pvt. Ltd.\",\"leave_type\":\"Sick Leave\",\"employee_name\":\"Pratima S\",\"department\":null,\"employee\":\"EMP-TB-00005\",\"from_date\":\"2018-05-29\",\"half_day_date\":\"\",\"to_date\":\"2018-05-30\",\"total_leave_days\":2,\"leave_balance\":12}",
		"action": "Save",
		"cmd": "frappe.desk.form.save.savedocs"
	},
	"btn": {
		"jQuery224085849009445780081": {
			"events": {
				"click": [
					{
						"type": "click",
						"origType": "click",
						"guid": 217,
						"namespace": ""
					}
				]
			}
		}
	},
	"freeze": true,
	"url": "/"
}

Response JSON

{
	"_server_messages": "[\"{\\\"message\\\": \\\"Did not save\\\"}\"]"
}

Later I had receieved a solution by Suraj to address this issue. The solution is as follows which resolved the issue

  1. Run bench --site console
  2. In the console enter frappe.db.sql_ddl(“”“ALTER TABLE tabLeave Type CHANGE max_days_allowed max_continuous_days_allowed int(8) NOT NULL;”“”)
  3. Then frappe.db.commit()
  4. Exit the console and restart your bench server (Optional).

Once this was done i started facing issue in opening the leave type page.
Then i receieved a solution from Mr. Zarrar Shaikh. Which was not helping out the following is the solutions provided and error reproduced

  1. Run bench --site console
  2. In the console enter
    frappe.reload_doc(“hr”, “doctype”, “leave_type”)
  3. Then frappe.model.utils.rename_field import rename_field
  4. Then rename_field(“Leave Type”, “max_days_allowed”, “max_continuous_days_allowed”)
  5. Then frappe.db.commit()
  6. Exit the console and restart your bench server (Optional).

Can anyone help in this regard. As my business activity is stuck due to this error.

Hey Guys over there. Can anyone help us out in resolving this bug.

I thing you are working old version. So you can take latest pull from ERPNext and frappe. Created new
setup environment.

Used latest version:
Installed Apps
ERPNext: v10.1.35 (solufy_report)
Frappe Framework: v11.x.x-develop (c64c13c) (develop)

Thanks.

How to do that can you let me know the commands for doing this.

I have the latest Version below is the version detail
App Versions
{
“erpnext”: “10.1.36”,
“frappe”: “10.1.35”
}

You can checked erpnext and frappe version using init.py or Help > About menu.

Thanks.

I have this in the about menu.

Installed Apps
ERPNext: v11.x.x-develop (f9f35d0) (develop)
Frappe Framework: v11.x.x-develop (1865d54) (develop)

Any developer who what to assist us.

Hey guys @Solufy @nabinhait @rmehta Kindly help me in this regard thank you in advance. Please guys i really need your help.

Can you run bench update again from frappe-bench directory? And then try creating Leave Application.

Thanks This resolved my issue this time after update.

1 Like