From 53259fb91fc92ee9ff102e2665c57d2483459982 Mon Sep 17 00:00:00 2001 From: Manas Solanki Date: Thu, 23 Feb 2017 13:26:31 +0530 Subject: [PATCH 1/2] Change in student master should reflect in every linked doctype and child doctype --- erpnext/schools/doctype/student/student.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/erpnext/schools/doctype/student/student.py b/erpnext/schools/doctype/student/student.py index b660bb33639..7b6dd2c06db 100644 --- a/erpnext/schools/doctype/student/student.py +++ b/erpnext/schools/doctype/student/student.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document from frappe import _ +from frappe.desk.form.linked_with import get_linked_doctypes class Student(Document): def validate(self): @@ -15,6 +16,22 @@ class Student(Document): self.check_unique() self.update_applicant_status() + if frappe.get_value("Student", self.name, "title") != self.title: + linked_doctypes = get_linked_doctypes("Student") + print linked_doctypes + for d in linked_doctypes: + print d,linked_doctypes[d] + if "child_doctype" not in linked_doctypes[d].keys() and "student_name" in [f.fieldname for f in frappe.get_meta(d).fields]: + print "in doctype" + frappe.db.sql("""UPDATE `tab{0}` set student_name = %s where {1} = %s""" + .format(d, linked_doctypes[d]["fieldname"]),(self.title, self.name)) + + elif "child_doctype" in linked_doctypes[d].keys() and "student_name" in \ + [f.fieldname for f in frappe.get_meta(linked_doctypes[d]["child_doctype"]).fields]: + print "in child doctypes" + frappe.db.sql("""UPDATE `tab{0}` set student_name = %s where {1} = %s""" + .format(linked_doctypes[d]["child_doctype"], linked_doctypes[d]["fieldname"]),(self.title, self.name)) + def check_unique(self): """Validates if the Student Applicant is Unique""" student = frappe.db.sql("select name from `tabStudent` where student_applicant=%s and name!=%s", (self.student_applicant, self.name)) From 230df2c9d3d09196d8e469ca9af2a2b2f4e4e3dd Mon Sep 17 00:00:00 2001 From: Manas Solanki Date: Fri, 24 Feb 2017 12:09:55 +0530 Subject: [PATCH 2/2] Link the sibling child table with the student doctype --- erpnext/schools/doctype/student/student.py | 25 ++- .../student_applicant/student_applicant.js | 14 +- .../student_sibling/student_sibling.json | 145 ++++++++++++++---- 3 files changed, 139 insertions(+), 45 deletions(-) diff --git a/erpnext/schools/doctype/student/student.py b/erpnext/schools/doctype/student/student.py index 7b6dd2c06db..a830e5bdc06 100644 --- a/erpnext/schools/doctype/student/student.py +++ b/erpnext/schools/doctype/student/student.py @@ -17,20 +17,19 @@ class Student(Document): self.update_applicant_status() if frappe.get_value("Student", self.name, "title") != self.title: - linked_doctypes = get_linked_doctypes("Student") - print linked_doctypes - for d in linked_doctypes: - print d,linked_doctypes[d] - if "child_doctype" not in linked_doctypes[d].keys() and "student_name" in [f.fieldname for f in frappe.get_meta(d).fields]: - print "in doctype" - frappe.db.sql("""UPDATE `tab{0}` set student_name = %s where {1} = %s""" - .format(d, linked_doctypes[d]["fieldname"]),(self.title, self.name)) + self.update_student_name_in_linked_doctype() - elif "child_doctype" in linked_doctypes[d].keys() and "student_name" in \ - [f.fieldname for f in frappe.get_meta(linked_doctypes[d]["child_doctype"]).fields]: - print "in child doctypes" - frappe.db.sql("""UPDATE `tab{0}` set student_name = %s where {1} = %s""" - .format(linked_doctypes[d]["child_doctype"], linked_doctypes[d]["fieldname"]),(self.title, self.name)) + def update_student_name_in_linked_doctype(self): + linked_doctypes = get_linked_doctypes("Student") + for d in linked_doctypes: + if "student_name" in [f.fieldname for f in frappe.get_meta(d).fields]: + frappe.db.sql("""UPDATE `tab{0}` set student_name = %s where {1} = %s""" + .format(d, linked_doctypes[d]["fieldname"]),(self.title, self.name)) + + if "child_doctype" in linked_doctypes[d].keys() and "student_name" in \ + [f.fieldname for f in frappe.get_meta(linked_doctypes[d]["child_doctype"]).fields]: + frappe.db.sql("""UPDATE `tab{0}` set student_name = %s where {1} = %s""" + .format(linked_doctypes[d]["child_doctype"], linked_doctypes[d]["fieldname"]),(self.title, self.name)) def check_unique(self): """Validates if the Student Applicant is Unique""" diff --git a/erpnext/schools/doctype/student_applicant/student_applicant.js b/erpnext/schools/doctype/student_applicant/student_applicant.js index 36baa80bb95..c14c6f749c6 100644 --- a/erpnext/schools/doctype/student_applicant/student_applicant.js +++ b/erpnext/schools/doctype/student_applicant/student_applicant.js @@ -1,3 +1,6 @@ +// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + frappe.ui.form.on("Student Applicant", { refresh: function(frm) { if(frm.doc.application_status== "Applied" && frm.doc.docstatus== 1 ) { @@ -26,4 +29,13 @@ frappe.ui.form.on("Student Applicant", { frm: frm }) } -}); \ No newline at end of file +}); + + +frappe.ui.form.on('Student Sibling', { + student: function(frm) { + frm.add_fetch("student", "title", "full_name"); + frm.add_fetch("student", "gender", "gender"); + frm.add_fetch("student", "date_of_birth", "date_of_birth"); + } +}); diff --git a/erpnext/schools/doctype/student_sibling/student_sibling.json b/erpnext/schools/doctype/student_sibling/student_sibling.json index b74d48ce875..87cdbf19afa 100644 --- a/erpnext/schools/doctype/student_sibling/student_sibling.json +++ b/erpnext/schools/doctype/student_sibling/student_sibling.json @@ -10,6 +10,36 @@ "document_type": "", "editable_grid": 1, "fields": [ + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "studying_in_same_institute", + "fieldtype": "Select", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Studying in Same Institute", + "length": 0, + "no_copy": 0, + "options": "NO\nYES", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -21,7 +51,9 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Full Name", "length": 0, "no_copy": 0, @@ -31,8 +63,9 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, + "remember_last_selected_value": 0, "report_hide": 0, - "reqd": 1, + "reqd": 0, "search_index": 0, "set_only_once": 0, "unique": 0 @@ -48,7 +81,9 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Gender", "length": 0, "no_copy": 0, @@ -59,32 +94,7 @@ "print_hide_if_no_value": 0, "print_width": "", "read_only": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "unique": 0 - }, - { - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 2, - "fieldname": "date_of_birth", - "fieldtype": "Date", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_list_view": 1, - "label": "Date of Birth", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -102,7 +112,9 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, + "in_standard_filter": 0, "length": 0, "no_copy": 0, "permlevel": 0, @@ -110,6 +122,68 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "depends_on": "eval:doc.studying_in_same_institute == \"YES\"", + "fieldname": "student", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Student ID", + "length": 0, + "no_copy": 0, + "options": "Student", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 2, + "depends_on": "eval:doc.studying_in_same_institute == \"NO\"", + "fieldname": "institution", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Institution", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -127,7 +201,9 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, + "in_standard_filter": 0, "label": "Program", "length": 0, "no_copy": 0, @@ -136,6 +212,7 @@ "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -147,21 +224,25 @@ "bold": 0, "collapsible": 0, "columns": 2, - "fieldname": "institution", - "fieldtype": "Data", + "fieldname": "date_of_birth", + "fieldtype": "Date", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, - "label": "Institution", + "in_standard_filter": 0, + "label": "Date of Birth", "length": 0, "no_copy": 0, + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, + "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, "search_index": 0, @@ -179,7 +260,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2016-09-14 06:03:44.067781", + "modified": "2017-02-24 11:43:01.311010", "modified_by": "Administrator", "module": "Schools", "name": "Student Sibling", @@ -189,7 +270,9 @@ "quick_entry": 1, "read_only": 0, "read_only_onload": 0, + "show_name_in_global_search": 0, "sort_field": "modified", "sort_order": "DESC", + "track_changes": 0, "track_seen": 0 } \ No newline at end of file