mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 08:54:45 +00:00
Change in student master should reflect in every linked doctype and child doctype
This commit is contained in:
@@ -6,6 +6,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
from frappe.desk.form.linked_with import get_linked_doctypes
|
||||||
|
|
||||||
class Student(Document):
|
class Student(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
@@ -15,6 +16,22 @@ class Student(Document):
|
|||||||
self.check_unique()
|
self.check_unique()
|
||||||
self.update_applicant_status()
|
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):
|
def check_unique(self):
|
||||||
"""Validates if the Student Applicant is Unique"""
|
"""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))
|
student = frappe.db.sql("select name from `tabStudent` where student_applicant=%s and name!=%s", (self.student_applicant, self.name))
|
||||||
|
|||||||
Reference in New Issue
Block a user