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
- Run bench --site console
- In the console enter frappe.db.sql_ddl(“”“ALTER TABLE
tabLeave Type
CHANGE max_days_allowed
max_continuous_days_allowed
int(8) NOT NULL;”“”)
- Then frappe.db.commit()
- 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
- Run bench --site console
- In the console enter
frappe.reload_doc(“hr”, “doctype”, “leave_type”)
- Then frappe.model.utils.rename_field import rename_field
- Then rename_field(“Leave Type”, “max_days_allowed”, “max_continuous_days_allowed”)
- Then frappe.db.commit()
- Exit the console and restart your bench server (Optional).