Getting errors in Education App

I am getting lot of error in the Education App.

Here is ne of the error that I am getting when trying to create a new Student.

App Versions

{
	"education": "0.0.1",
	"erpnext": "14.11.0",
	"frappe": "14.20.0",
	"hrms": "1.0.0",
	"india_compliance": "14.0.8",
	"payments": "0.0.1"
}

Route

Form/Student/new-student-1

Trackeback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 69, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 45, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 83, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1590, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/save.py", line 23, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 304, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 326, in _save
    return self.insert()
  File "apps/frappe/frappe/model/document.py", line 258, in insert
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1039, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 908, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1260, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1242, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 905, in fn
    return method_object(*args, **kwargs)
  File "apps/education/education/education/doctype/student/student.py", line 27, in validate
    self.update_student_name_in_linked_doctype()
  File "apps/education/education/education/doctype/student/student.py", line 57, in update_student_name_in_linked_doctype
    frappe.db.sql(
  File "apps/frappe/frappe/database/database.py", line 218, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 148, in execute
    result = self._query(query)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 310, in _query
    conn.query(q)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 548, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 775, in _read_query_result
    result.read()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1156, in read
    first_packet = self.connection._read_packet()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 725, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1054, "Unknown column 'student' in 'where clause'")

Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"docstatus\":0,\"doctype\":\"Student\",\"name\":\"new-student-1\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"enabled\":1,\"naming_series\":\"EDU-STU-.YYYY.-\",\"joining_date\":\"2022-12-27\",\"blood_group\":\"\",\"country\":\"India\",\"first_name\":\"Student\",\"last_name\":\"One\",\"student_email_id\":\"student1@gmail.com\",\"gender\":\"Male\"}",
		"action": "Save"
	},
	"btn": {
		"jQuery36000407205640406730351": {
			"events": {
				"click": [
					{
						"type": "click",
						"origType": "click",
						"guid": 586,
						"namespace": ""
					}
				]
			}
		}
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.save.savedocs"
}

Response Data

{
	"exception": "pymysql.err.OperationalError: (1054, \"Unknown column 'student' in 'where clause'\")"
}

How to solve this problem?

Regards,

1 Like

It seems there is some problem in this statement in the file student.py.

frappe.db.sql(
						"""UPDATE `tab{0}` set student_name = %s where {1} = %s""".format(
							d, linked_doctypes[d]["fieldname"][0]
						),
						(self.student_name, self.name),
					)

Any idea what is the mistake in this statement?

Regards,

Hello,

I have not installed or used Education App but I think you need to replace the code as follows in file student.py @ line # 57:

field = meta.get_field(linked_doctypes[d]["fieldname"][0])
if field:
     frappe.db.set_value(d, self.name, "student_name", self.student_name)

Note: This code is courtesy of ChatGPT.

TIA

Yogi Yang

1 Like

@yogeshvachhani the issue has been resolved. fix: change title references to student_name by pateljannat · Pull Request #82 · frappe/education · GitHub

1 Like