Addition of few more fields in student contact report
diff --git a/erpnext/schools/report/student_and_guardian_contact_details/student_and_guardian_contact_details.py b/erpnext/schools/report/student_and_guardian_contact_details/student_and_guardian_contact_details.py
index 5258bf4..2e59d61 100644
--- a/erpnext/schools/report/student_and_guardian_contact_details/student_and_guardian_contact_details.py
+++ b/erpnext/schools/report/student_and_guardian_contact_details/student_and_guardian_contact_details.py
@@ -22,11 +22,13 @@
if not student_list:
return columns, []
- student_mobile_map = get_student_mobile_no(student_list)
+ student_map = get_student_details(student_list)
guardian_map = get_guardian_map(student_list)
for d in program_enrollments:
- row = [d.student, d.student_name, student_mobile_map.get(d.student)]
+ student_details = student_map.get(d.student)
+ row = [d.student, d.student_name, student_details.get("student_mobile_number"), student_details.get("student_email_id"),
+ student_details.get("address")]
student_guardians = guardian_map.get(d.student)
@@ -34,7 +36,7 @@
for i in xrange(2):
if i < len(student_guardians):
g = student_guardians[i]
- row += [g.guardian_name, g.relation, g.mobile_number]
+ row += [g.guardian_name, g.relation, g.mobile_number, g.email_address]
data.append(row)
@@ -46,23 +48,31 @@
_("Student ID") + ":Link/Student:90",
_("Student Name") + "::150",
_("Student Mobile No.") + "::110",
+ _("Student Email ID") + "::125",
+ _("Student Address") + "::175",
_("Guardian1 Name") + "::150",
_("Relation with Guardian1") + "::80",
_("Guardian1 Mobile No") + "::125",
+ _("Guardian1 Email ID") + "::125",
_("Guardian2 Name") + "::150",
_("Relation with Guardian2") + "::80",
_("Guardian2 Mobile No") + "::125",
+ _("Guardian2 Email ID") + "::125",
]
return columns
-def get_student_mobile_no(student_list):
- student_mobile_map = frappe._dict()
- student_mobile_no = frappe.db.sql('''
- select name, student_mobile_number from `tabStudent` where name in (%s)''' %
+def get_student_details(student_list):
+ student_map = frappe._dict()
+ student_details = frappe.db.sql('''
+ select name, student_mobile_number, student_email_id, address_line_1, address_line_2, city, state from `tabStudent` where name in (%s)''' %
', '.join(['%s']*len(student_list)), tuple(student_list), as_dict=1)
- for s in student_mobile_no:
- student_mobile_map[s.name] = s.student_mobile_number
- return student_mobile_map
+ for s in student_details:
+ student = frappe._dict()
+ student["student_mobile_number"] = s.student_mobile_number
+ student["student_email_id"] = s.student_email_id
+ student["address"] = ', '.join([d for d in [s.address_line_1, s.address_line_2, s.city, s.state] if d])
+ student_map[s.name] = student
+ return student_map
def get_guardian_map(student_list):
guardian_map = frappe._dict()
@@ -75,8 +85,12 @@
guardian_mobile_no = dict(frappe.db.sql("""select name, mobile_number from `tabGuardian`
where name in (%s)""" % ", ".join(['%s']*len(guardian_list)), tuple(guardian_list)))
+ guardian_email_id = dict(frappe.db.sql("""select name, email_address from `tabGuardian`
+ where name in (%s)""" % ", ".join(['%s']*len(guardian_list)), tuple(guardian_list)))
+
for guardian in guardian_details:
guardian["mobile_number"] = guardian_mobile_no.get(guardian.guardian)
+ guardian["email_address"] = guardian_email_id.get(guardian.guardian)
guardian_map.setdefault(guardian.parent, []).append(guardian)
return guardian_map
\ No newline at end of file