fix(assessment_result): student must be in group (#15255)
* fix(assessment_result): student must be in group * fix(test_student_group): raise correct exception * fix(unused-import): assessment-plan.py * fix(tests) * fix(tests) * fix(test) * fix(tests)
This commit is contained in:
committed by
Nabin Hait
parent
1b73505391
commit
a2288ff8e7
@@ -0,0 +1,10 @@
|
|||||||
|
import frappe
|
||||||
|
from frappe import _
|
||||||
|
|
||||||
|
class StudentNotInGroupError(frappe.ValidationError): pass
|
||||||
|
|
||||||
|
def validate_student_belongs_to_group(student, student_group):
|
||||||
|
groups = frappe.db.get_all('Student Group Student', ['parent'], dict(student = student, active=1))
|
||||||
|
if not student_group in [d.parent for d in groups]:
|
||||||
|
frappe.throw(_('Student {0} does not belong to group {1}').format(frappe.bold(student), frappe.bold(student_group)),
|
||||||
|
StudentNotInGroupError)
|
||||||
|
|||||||
@@ -3,16 +3,6 @@
|
|||||||
|
|
||||||
|
|
||||||
frappe.ui.form.on("Assessment Plan", {
|
frappe.ui.form.on("Assessment Plan", {
|
||||||
setup: function(frm) {
|
|
||||||
frm.add_fetch("student_group", "course", "course");
|
|
||||||
frm.add_fetch("student_group", "program", "program");
|
|
||||||
frm.add_fetch("student_group", "academic_year", "academic_year");
|
|
||||||
frm.add_fetch("student_group", "academic_term", "academic_term");
|
|
||||||
frm.add_fetch("examiner", "instructor_name", "examiner_name");
|
|
||||||
frm.add_fetch("supervisor", "instructor_name", "supervisor_name");
|
|
||||||
frm.add_fetch("course", "default_grading_scale", "grading_scale");
|
|
||||||
},
|
|
||||||
|
|
||||||
onload: function(frm) {
|
onload: function(frm) {
|
||||||
frm.set_query("assessment_group", function(doc, cdt, cdn) {
|
frm.set_query("assessment_group", function(doc, cdt, cdn) {
|
||||||
return{
|
return{
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -9,38 +9,26 @@ from frappe import _
|
|||||||
|
|
||||||
class AssessmentPlan(Document):
|
class AssessmentPlan(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.set_missing_field()
|
|
||||||
self.validate_overlap()
|
self.validate_overlap()
|
||||||
self.validate_max_score()
|
self.validate_max_score()
|
||||||
self.validate_assessment_criteria()
|
self.validate_assessment_criteria()
|
||||||
|
|
||||||
def set_missing_field(self):
|
|
||||||
if self.student_group:
|
|
||||||
academic_term, academic_year, program, course = frappe.get_value("Student Group", self.student_group,
|
|
||||||
["academic_term", "academic_year", "program", "course"])
|
|
||||||
self.academic_term = academic_term
|
|
||||||
self.academic_year = academic_year
|
|
||||||
if program:
|
|
||||||
self.program = program
|
|
||||||
if course and not self.course: #pylint: disable=E0203
|
|
||||||
self.course = course
|
|
||||||
|
|
||||||
def validate_overlap(self):
|
def validate_overlap(self):
|
||||||
"""Validates overlap for Student Group, Instructor, Room"""
|
"""Validates overlap for Student Group, Instructor, Room"""
|
||||||
|
|
||||||
from erpnext.education.utils import validate_overlap_for
|
from erpnext.education.utils import validate_overlap_for
|
||||||
|
|
||||||
#Validate overlapping course schedules.
|
#Validate overlapping course schedules.
|
||||||
if self.student_group:
|
if self.student_group:
|
||||||
validate_overlap_for(self, "Course Schedule", "student_group")
|
validate_overlap_for(self, "Course Schedule", "student_group")
|
||||||
|
|
||||||
validate_overlap_for(self, "Course Schedule", "instructor")
|
validate_overlap_for(self, "Course Schedule", "instructor")
|
||||||
validate_overlap_for(self, "Course Schedule", "room")
|
validate_overlap_for(self, "Course Schedule", "room")
|
||||||
|
|
||||||
#validate overlapping assessment schedules.
|
#validate overlapping assessment schedules.
|
||||||
if self.student_group:
|
if self.student_group:
|
||||||
validate_overlap_for(self, "Assessment Plan", "student_group")
|
validate_overlap_for(self, "Assessment Plan", "student_group")
|
||||||
|
|
||||||
validate_overlap_for(self, "Assessment Plan", "room")
|
validate_overlap_for(self, "Assessment Plan", "room")
|
||||||
validate_overlap_for(self, "Assessment Plan", "supervisor", self.supervisor)
|
validate_overlap_for(self, "Assessment Plan", "supervisor", self.supervisor)
|
||||||
|
|
||||||
|
|||||||
@@ -2,18 +2,6 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Assessment Result", {
|
frappe.ui.form.on("Assessment Result", {
|
||||||
setup: function(frm) {
|
|
||||||
frm.add_fetch("student", "title", "student_name");
|
|
||||||
frm.add_fetch("assessment_plan", "course", "course");
|
|
||||||
frm.add_fetch("assessment_plan", "program", "program");
|
|
||||||
frm.add_fetch("assessment_plan", "academic_year", "academic_year");
|
|
||||||
frm.add_fetch("assessment_plan", "academic_term", "academic_term");
|
|
||||||
frm.add_fetch("assessment_plan", "grading_scale", "grading_scale");
|
|
||||||
frm.add_fetch("assessment_plan", "student_group", "student_group");
|
|
||||||
frm.add_fetch("assessment_plan", "assessment_group", "assessment_group");
|
|
||||||
frm.add_fetch("assessment_plan", "maximum_assessment_score", "maximum_score");
|
|
||||||
},
|
|
||||||
|
|
||||||
onload: function(frm) {
|
onload: function(frm) {
|
||||||
frm.set_query('assessment_plan', function(){
|
frm.set_query('assessment_plan', function(){
|
||||||
return {
|
return {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -10,28 +10,15 @@ from frappe.model.document import Document
|
|||||||
from erpnext.education.api import get_grade
|
from erpnext.education.api import get_grade
|
||||||
from erpnext.education.api import get_assessment_details
|
from erpnext.education.api import get_assessment_details
|
||||||
from frappe.utils.csvutils import getlink
|
from frappe.utils.csvutils import getlink
|
||||||
|
import erpnext.education
|
||||||
|
|
||||||
class AssessmentResult(Document):
|
class AssessmentResult(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.set_missing_values()
|
erpnext.education.validate_student_belongs_to_group(self.student, self.student_group)
|
||||||
self.validate_maximum_score()
|
self.validate_maximum_score()
|
||||||
self.validate_grade()
|
self.validate_grade()
|
||||||
self.validate_duplicate()
|
self.validate_duplicate()
|
||||||
|
|
||||||
def set_missing_values(self):
|
|
||||||
if self.student and not self.student_name:
|
|
||||||
self.student_name = frappe.db.get_value("Student", self.student, "title")
|
|
||||||
assessment_plan_details = frappe.get_value("Assessment Plan", self.assessment_plan, ["academic_term",
|
|
||||||
"academic_year", "program", "course", "grading_scale", "assessment_group", "student_group",
|
|
||||||
"maximum_assessment_score"], as_dict=1)
|
|
||||||
|
|
||||||
for field in assessment_plan_details:
|
|
||||||
if field != "maximum_assessment_score":
|
|
||||||
setattr(self, field, assessment_plan_details[field])
|
|
||||||
else:
|
|
||||||
self.maximum_score = assessment_plan_details[field]
|
|
||||||
|
|
||||||
def validate_maximum_score(self):
|
def validate_maximum_score(self):
|
||||||
assessment_details = get_assessment_details(self.assessment_plan)
|
assessment_details = get_assessment_details(self.assessment_plan)
|
||||||
max_scores = {}
|
max_scores = {}
|
||||||
@@ -42,7 +29,7 @@ class AssessmentResult(Document):
|
|||||||
d.maximum_score = max_scores.get(d.assessment_criteria)
|
d.maximum_score = max_scores.get(d.assessment_criteria)
|
||||||
if d.score > d.maximum_score:
|
if d.score > d.maximum_score:
|
||||||
frappe.throw(_("Score cannot be greater than Maximum Score"))
|
frappe.throw(_("Score cannot be greater than Maximum Score"))
|
||||||
|
|
||||||
def validate_grade(self):
|
def validate_grade(self):
|
||||||
self.total_score = 0.0
|
self.total_score = 0.0
|
||||||
for d in self.details:
|
for d in self.details:
|
||||||
|
|||||||
@@ -1,216 +1,226 @@
|
|||||||
{
|
{
|
||||||
"allow_copy": 0,
|
"allow_copy": 0,
|
||||||
"allow_guest_to_view": 0,
|
"allow_guest_to_view": 0,
|
||||||
"allow_import": 0,
|
"allow_import": 0,
|
||||||
"allow_rename": 1,
|
"allow_rename": 1,
|
||||||
"autoname": "field:grading_scale_name",
|
"autoname": "field:grading_scale_name",
|
||||||
"beta": 0,
|
"beta": 0,
|
||||||
"creation": "2016-08-26 03:06:53.922972",
|
"creation": "2016-08-26 03:06:53.922972",
|
||||||
"custom": 0,
|
"custom": 0,
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"document_type": "",
|
"document_type": "",
|
||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_in_quick_entry": 0,
|
||||||
"bold": 0,
|
"allow_on_submit": 0,
|
||||||
"collapsible": 0,
|
"bold": 0,
|
||||||
"columns": 0,
|
"collapsible": 0,
|
||||||
"fieldname": "grading_scale_name",
|
"columns": 0,
|
||||||
"fieldtype": "Data",
|
"fieldname": "grading_scale_name",
|
||||||
"hidden": 0,
|
"fieldtype": "Data",
|
||||||
"ignore_user_permissions": 0,
|
"hidden": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_global_search": 0,
|
||||||
"in_standard_filter": 0,
|
"in_list_view": 0,
|
||||||
"label": "Grading Scale Name",
|
"in_standard_filter": 0,
|
||||||
"length": 0,
|
"label": "Grading Scale Name",
|
||||||
"no_copy": 0,
|
"length": 0,
|
||||||
"permlevel": 0,
|
"no_copy": 0,
|
||||||
"precision": "",
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"precision": "",
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide": 0,
|
||||||
"read_only": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"remember_last_selected_value": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"remember_last_selected_value": 0,
|
||||||
"reqd": 1,
|
"report_hide": 0,
|
||||||
"search_index": 0,
|
"reqd": 1,
|
||||||
"set_only_once": 0,
|
"search_index": 0,
|
||||||
"unique": 0
|
"set_only_once": 0,
|
||||||
},
|
"translatable": 0,
|
||||||
|
"unique": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_in_quick_entry": 0,
|
||||||
"bold": 0,
|
"allow_on_submit": 0,
|
||||||
"collapsible": 0,
|
"bold": 0,
|
||||||
"columns": 0,
|
"collapsible": 0,
|
||||||
"fieldname": "description",
|
"columns": 0,
|
||||||
"fieldtype": "Small Text",
|
"fieldname": "grading_intervals_section",
|
||||||
"hidden": 0,
|
"fieldtype": "Section Break",
|
||||||
"ignore_user_permissions": 0,
|
"hidden": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 1,
|
"in_global_search": 0,
|
||||||
"in_standard_filter": 0,
|
"in_list_view": 0,
|
||||||
"label": "Description",
|
"in_standard_filter": 0,
|
||||||
"length": 0,
|
"label": "Grading Scale Intervals",
|
||||||
"no_copy": 0,
|
"length": 0,
|
||||||
"permlevel": 0,
|
"no_copy": 0,
|
||||||
"precision": "",
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"precision": "",
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide": 0,
|
||||||
"read_only": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"remember_last_selected_value": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"remember_last_selected_value": 0,
|
||||||
"reqd": 0,
|
"report_hide": 0,
|
||||||
"search_index": 0,
|
"reqd": 0,
|
||||||
"set_only_once": 0,
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_in_quick_entry": 0,
|
||||||
"bold": 0,
|
"allow_on_submit": 0,
|
||||||
"collapsible": 0,
|
"bold": 0,
|
||||||
"columns": 0,
|
"collapsible": 0,
|
||||||
"fieldname": "grading_intervals_section",
|
"columns": 0,
|
||||||
"fieldtype": "Section Break",
|
"fieldname": "intervals",
|
||||||
"hidden": 0,
|
"fieldtype": "Table",
|
||||||
"ignore_user_permissions": 0,
|
"hidden": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_global_search": 0,
|
||||||
"in_standard_filter": 0,
|
"in_list_view": 0,
|
||||||
"label": "Grading Scale Intervals",
|
"in_standard_filter": 0,
|
||||||
"length": 0,
|
"label": "Intervals",
|
||||||
"no_copy": 0,
|
"length": 0,
|
||||||
"permlevel": 0,
|
"no_copy": 0,
|
||||||
"precision": "",
|
"options": "Grading Scale Interval",
|
||||||
"print_hide": 0,
|
"permlevel": 0,
|
||||||
"print_hide_if_no_value": 0,
|
"precision": "",
|
||||||
"read_only": 0,
|
"print_hide": 0,
|
||||||
"remember_last_selected_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"report_hide": 0,
|
"read_only": 0,
|
||||||
"reqd": 0,
|
"remember_last_selected_value": 0,
|
||||||
"search_index": 0,
|
"report_hide": 0,
|
||||||
"set_only_once": 0,
|
"reqd": 1,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_in_quick_entry": 0,
|
||||||
"bold": 0,
|
"allow_on_submit": 0,
|
||||||
"collapsible": 0,
|
"bold": 0,
|
||||||
"columns": 0,
|
"collapsible": 0,
|
||||||
"fieldname": "intervals",
|
"columns": 0,
|
||||||
"fieldtype": "Table",
|
"fieldname": "amended_from",
|
||||||
"hidden": 0,
|
"fieldtype": "Link",
|
||||||
"ignore_user_permissions": 0,
|
"hidden": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_global_search": 0,
|
||||||
"in_standard_filter": 0,
|
"in_list_view": 0,
|
||||||
"label": "Intervals",
|
"in_standard_filter": 0,
|
||||||
"length": 0,
|
"label": "Amended From",
|
||||||
"no_copy": 0,
|
"length": 0,
|
||||||
"options": "Grading Scale Interval",
|
"no_copy": 1,
|
||||||
"permlevel": 0,
|
"options": "Grading Scale",
|
||||||
"precision": "",
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 1,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 1,
|
||||||
"remember_last_selected_value": 0,
|
"remember_last_selected_value": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 1,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_in_quick_entry": 0,
|
||||||
"bold": 0,
|
"allow_on_submit": 0,
|
||||||
"collapsible": 0,
|
"bold": 0,
|
||||||
"columns": 0,
|
"collapsible": 0,
|
||||||
"fieldname": "amended_from",
|
"columns": 0,
|
||||||
"fieldtype": "Link",
|
"fieldname": "description",
|
||||||
"hidden": 0,
|
"fieldtype": "Small Text",
|
||||||
"ignore_user_permissions": 0,
|
"hidden": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_global_search": 0,
|
||||||
"in_standard_filter": 0,
|
"in_list_view": 1,
|
||||||
"label": "Amended From",
|
"in_standard_filter": 0,
|
||||||
"length": 0,
|
"label": "Description",
|
||||||
"no_copy": 1,
|
"length": 0,
|
||||||
"options": "Grading Scale",
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"precision": "",
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide": 0,
|
||||||
"read_only": 1,
|
"print_hide_if_no_value": 0,
|
||||||
"remember_last_selected_value": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"remember_last_selected_value": 0,
|
||||||
"reqd": 0,
|
"report_hide": 0,
|
||||||
"search_index": 0,
|
"reqd": 0,
|
||||||
"set_only_once": 0,
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_web_view": 0,
|
"has_web_view": 0,
|
||||||
"hide_heading": 0,
|
"hide_heading": 0,
|
||||||
"hide_toolbar": 0,
|
"hide_toolbar": 0,
|
||||||
"idx": 0,
|
"idx": 0,
|
||||||
"image_view": 0,
|
"image_view": 0,
|
||||||
"in_create": 0,
|
"in_create": 0,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2017-11-10 19:07:22.001040",
|
"modified": "2018-08-30 00:34:03.368432",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Education",
|
"module": "Education",
|
||||||
"name": "Grading Scale",
|
"name": "Grading Scale",
|
||||||
"name_case": "",
|
"name_case": "",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
"amend": 0,
|
"amend": 0,
|
||||||
"apply_user_permissions": 0,
|
"cancel": 1,
|
||||||
"cancel": 1,
|
"create": 1,
|
||||||
"create": 1,
|
"delete": 1,
|
||||||
"delete": 1,
|
"email": 1,
|
||||||
"email": 1,
|
"export": 1,
|
||||||
"export": 1,
|
"if_owner": 0,
|
||||||
"if_owner": 0,
|
"import": 0,
|
||||||
"import": 0,
|
"permlevel": 0,
|
||||||
"permlevel": 0,
|
"print": 1,
|
||||||
"print": 1,
|
"read": 1,
|
||||||
"read": 1,
|
"report": 1,
|
||||||
"report": 1,
|
"role": "Academics User",
|
||||||
"role": "Academics User",
|
"set_user_permissions": 0,
|
||||||
"set_user_permissions": 0,
|
"share": 1,
|
||||||
"share": 1,
|
"submit": 1,
|
||||||
"submit": 1,
|
|
||||||
"write": 1
|
"write": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"quick_entry": 1,
|
"quick_entry": 1,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"read_only_onload": 0,
|
"read_only_onload": 0,
|
||||||
"restrict_to_domain": "Education",
|
"restrict_to_domain": "Education",
|
||||||
"show_name_in_global_search": 0,
|
"show_name_in_global_search": 0,
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"title_field": "",
|
"title_field": "",
|
||||||
"track_changes": 0,
|
"track_changes": 0,
|
||||||
"track_seen": 0
|
"track_seen": 0,
|
||||||
|
"track_views": 0
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
"date_of_birth": "2000-01-01",
|
"date_of_birth": "2000-01-01",
|
||||||
"gender": "Male",
|
"gender": "Male",
|
||||||
"blood_group": "A+"
|
"blood_group": "A+"
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"first_name": "_Test",
|
"first_name": "_Test",
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
"date_of_birth": "2000-01-01",
|
"date_of_birth": "2000-01-01",
|
||||||
"gender": "Male",
|
"gender": "Male",
|
||||||
"blood_group": "A+"
|
"blood_group": "A+"
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"first_name": "_Test",
|
"first_name": "_Test",
|
||||||
@@ -27,6 +27,26 @@
|
|||||||
"date_of_birth": "2000-01-01",
|
"date_of_birth": "2000-01-01",
|
||||||
"gender": "Male",
|
"gender": "Male",
|
||||||
"blood_group": "A+"
|
"blood_group": "A+"
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"first_name": "_Test",
|
||||||
|
"middle_name": "Student",
|
||||||
|
"last_name": "Name 3",
|
||||||
|
"program": "TC101",
|
||||||
|
"date_of_birth": "2000-01-01",
|
||||||
|
"gender": "Male",
|
||||||
|
"blood_group": "A+"
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"first_name": "_Test",
|
||||||
|
"middle_name": "Student",
|
||||||
|
"last_name": "Name 4",
|
||||||
|
"program": "TC101",
|
||||||
|
"date_of_birth": "2000-01-01",
|
||||||
|
"gender": "Male",
|
||||||
|
"blood_group": "A+"
|
||||||
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -5,23 +5,38 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
from frappe.utils.make_random import get_random
|
import erpnext.education
|
||||||
|
|
||||||
|
def get_random_group():
|
||||||
|
doc = frappe.get_doc({
|
||||||
|
"doctype": "Student Group",
|
||||||
|
"student_group_name": "_Test Student Group-" + frappe.generate_hash(length=5),
|
||||||
|
"group_based_on": "Activity"
|
||||||
|
}).insert()
|
||||||
|
|
||||||
|
student_list = frappe.get_all('Student', limit=5)
|
||||||
|
|
||||||
|
doc.extend("students", [{"student":d.name, "active": 1} for d in student_list])
|
||||||
|
doc.save()
|
||||||
|
|
||||||
|
return doc
|
||||||
|
|
||||||
class TestStudentGroup(unittest.TestCase):
|
class TestStudentGroup(unittest.TestCase):
|
||||||
def test_student_roll_no(self):
|
def test_student_roll_no(self):
|
||||||
doc = frappe.get_doc({
|
doc = get_random_group()
|
||||||
"doctype": "Student Group",
|
self.assertEqual(max([d.group_roll_number for d in doc.students]), len(doc.students))
|
||||||
"student_group_name": "_Test Student Group R",
|
|
||||||
"group_based_on": "Activity"
|
|
||||||
}).insert()
|
|
||||||
|
|
||||||
student_list = []
|
def test_in_group(self):
|
||||||
while len(student_list) < 3:
|
doc = get_random_group()
|
||||||
s = get_random("Student")
|
|
||||||
if s not in student_list:
|
|
||||||
student_list.append(s)
|
|
||||||
|
|
||||||
doc.extend("students", [{"student":d} for d in student_list])
|
last_student = doc.students[-1].student
|
||||||
|
|
||||||
|
# remove last student
|
||||||
|
doc.students = doc.students[:-1]
|
||||||
doc.save()
|
doc.save()
|
||||||
self.assertEqual(max([d.group_roll_number for d in doc.students]), 3)
|
|
||||||
|
|
||||||
|
self.assertRaises(erpnext.education.StudentNotInGroupError,
|
||||||
|
erpnext.education.validate_student_belongs_to_group, last_student, doc.name)
|
||||||
|
|
||||||
|
# safe, don't throw validation
|
||||||
|
erpnext.education.validate_student_belongs_to_group(doc.students[0].student, doc.name)
|
||||||
|
|||||||
@@ -31,17 +31,20 @@ class TestEmployeeOnboarding(unittest.TestCase):
|
|||||||
onboarding.status = 'Pending'
|
onboarding.status = 'Pending'
|
||||||
onboarding.insert()
|
onboarding.insert()
|
||||||
onboarding.submit()
|
onboarding.submit()
|
||||||
self.assertEqual(onboarding.project, 'Employee Onboarding : Test Researcher - test@researcher.com')
|
|
||||||
self.assertRaises(IncompleteTaskError, make_employee, onboarding.name)
|
|
||||||
return onboarding
|
|
||||||
|
|
||||||
def test_employee_onboarding_completed_task(self):
|
self.assertEqual(onboarding.project, 'Employee Onboarding : Test Researcher - test@researcher.com')
|
||||||
doc = self.test_employee_onboarding_incomplete_task()
|
|
||||||
project = frappe.get_doc('Project', doc.project)
|
# don't allow making employee if onboarding is not complete
|
||||||
|
self.assertRaises(IncompleteTaskError, make_employee, onboarding.name)
|
||||||
|
|
||||||
|
# complete the task
|
||||||
|
project = frappe.get_doc('Project', onboarding.project)
|
||||||
project.tasks[0].status = 'Closed'
|
project.tasks[0].status = 'Closed'
|
||||||
project.save()
|
project.save()
|
||||||
doc.reload()
|
|
||||||
employee = make_employee(doc.name)
|
# make employee
|
||||||
|
onboarding.reload()
|
||||||
|
employee = make_employee(onboarding.name)
|
||||||
employee.first_name = employee.employee_name
|
employee.first_name = employee.employee_name
|
||||||
employee.date_of_joining = nowdate()
|
employee.date_of_joining = nowdate()
|
||||||
employee.date_of_birth = '1990-05-08'
|
employee.date_of_birth = '1990-05-08'
|
||||||
|
|||||||
@@ -546,7 +546,7 @@
|
|||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 1,
|
||||||
"label": "Leave Period",
|
"label": "Leave Period",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
@@ -676,7 +676,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2018-08-29 06:33:54.651196",
|
"modified": "2018-08-29 23:52:52.683844",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "HR",
|
"module": "HR",
|
||||||
"name": "Leave Allocation",
|
"name": "Leave Allocation",
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ frappe.ui.form.on('Leave Period', {
|
|||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if(!r.exc) {
|
if(!r.exc) {
|
||||||
d.hide();
|
d.hide();
|
||||||
|
frm.reload_doc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -53,24 +53,6 @@ def before_tests():
|
|||||||
frappe.db.set_value("Stock Settings", None, "auto_insert_price_list_rate_if_missing", 0)
|
frappe.db.set_value("Stock Settings", None, "auto_insert_price_list_rate_if_missing", 0)
|
||||||
enable_all_roles_and_domains()
|
enable_all_roles_and_domains()
|
||||||
|
|
||||||
if not frappe.db.exists('Company', 'Woocommerce'):
|
|
||||||
company = frappe.new_doc("Company")
|
|
||||||
company.company_name = "Woocommerce"
|
|
||||||
company.abbr = "W"
|
|
||||||
company.default_currency = "INR"
|
|
||||||
company.save()
|
|
||||||
|
|
||||||
woo_settings = frappe.get_doc("Woocommerce Settings")
|
|
||||||
if not woo_settings.secret:
|
|
||||||
woo_settings.secret = "ec434676aa1de0e502389f515c38f89f653119ab35e9117c7a79e576"
|
|
||||||
woo_settings.woocommerce_server_url = "https://woocommerce.mntechnique.com/"
|
|
||||||
woo_settings.api_consumer_key = "ck_fd43ff5756a6abafd95fadb6677100ce95a758a1"
|
|
||||||
woo_settings.api_consumer_secret = "cs_94360a1ad7bef7fa420a40cf284f7b3e0788454e"
|
|
||||||
woo_settings.enable_sync = 1
|
|
||||||
woo_settings.tax_account = "Sales Expenses - W"
|
|
||||||
woo_settings.f_n_f_account = "Expenses - W"
|
|
||||||
woo_settings.save(ignore_permissions=True)
|
|
||||||
|
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
|||||||
@@ -2,9 +2,24 @@ import unittest, frappe, requests, os, time, erpnext
|
|||||||
from erpnext.erpnext_integrations.connectors.woocommerce_connection import order
|
from erpnext.erpnext_integrations.connectors.woocommerce_connection import order
|
||||||
|
|
||||||
class TestWoocommerce(unittest.TestCase):
|
class TestWoocommerce(unittest.TestCase):
|
||||||
# def test_woocommerce_request(self):
|
def setup(self):
|
||||||
# r = emulate_request()
|
if not frappe.db.exists('Company', 'Woocommerce'):
|
||||||
# self.assertTrue(r.status_code == 200)
|
company = frappe.new_doc("Company")
|
||||||
|
company.company_name = "Woocommerce"
|
||||||
|
company.abbr = "W"
|
||||||
|
company.default_currency = "INR"
|
||||||
|
company.save()
|
||||||
|
|
||||||
|
woo_settings = frappe.get_doc("Woocommerce Settings")
|
||||||
|
if not woo_settings.secret:
|
||||||
|
woo_settings.secret = "ec434676aa1de0e502389f515c38f89f653119ab35e9117c7a79e576"
|
||||||
|
woo_settings.woocommerce_server_url = "https://woocommerce.mntechnique.com/"
|
||||||
|
woo_settings.api_consumer_key = "ck_fd43ff5756a6abafd95fadb6677100ce95a758a1"
|
||||||
|
woo_settings.api_consumer_secret = "cs_94360a1ad7bef7fa420a40cf284f7b3e0788454e"
|
||||||
|
woo_settings.enable_sync = 1
|
||||||
|
woo_settings.tax_account = "Sales Expenses - W"
|
||||||
|
woo_settings.f_n_f_account = "Expenses - W"
|
||||||
|
woo_settings.save(ignore_permissions=True)
|
||||||
|
|
||||||
def test_sales_order_for_woocommerece(self):
|
def test_sales_order_for_woocommerece(self):
|
||||||
data = {"id":75,"parent_id":0,"number":"74","order_key":"wc_order_5aa1281c2dacb","created_via":"checkout","version":"3.3.3","status":"processing","currency":"INR","date_created":"2018-03-08T12:10:04","date_created_gmt":"2018-03-08T12:10:04","date_modified":"2018-03-08T12:10:04","date_modified_gmt":"2018-03-08T12:10:04","discount_total":"0.00","discount_tax":"0.00","shipping_total":"150.00","shipping_tax":"0.00","cart_tax":"0.00","total":"649.00","total_tax":"0.00","prices_include_tax":False,"customer_id":12,"customer_ip_address":"103.54.99.5","customer_user_agent":"mozilla\\/5.0 (x11; linux x86_64) applewebkit\\/537.36 (khtml, like gecko) chrome\\/64.0.3282.186 safari\\/537.36","customer_note":"","billing":{"first_name":"Tony","last_name":"Stark","company":"Woocommerce","address_1":"Mumbai","address_2":"","city":"Dadar","state":"MH","postcode":"123","country":"IN","email":"tony@gmail.com","phone":"123457890"},"shipping":{"first_name":"Tony","last_name":"Stark","company":"","address_1":"Mumbai","address_2":"","city":"Dadar","state":"MH","postcode":"123","country":"IN"},"payment_method":"cod","payment_method_title":"Cash on delivery","transaction_id":"","date_paid":"","date_paid_gmt":"","date_completed":"","date_completed_gmt":"","cart_hash":"8e76b020d5790066496f244860c4703f","meta_data":[],"line_items":[{"id":80,"name":"Marvel","product_id":56,"variation_id":0,"quantity":1,"tax_class":"","subtotal":"499.00","subtotal_tax":"0.00","total":"499.00","total_tax":"0.00","taxes":[],"meta_data":[],"sku":"","price":499}],"tax_lines":[],"shipping_lines":[{"id":81,"method_title":"Flat rate","method_id":"flat_rate:1","total":"150.00","total_tax":"0.00","taxes":[],"meta_data":[{"id":623,"key":"Items","value":"Marvel × 1"}]}],"fee_lines":[],"coupon_lines":[],"refunds":[]}
|
data = {"id":75,"parent_id":0,"number":"74","order_key":"wc_order_5aa1281c2dacb","created_via":"checkout","version":"3.3.3","status":"processing","currency":"INR","date_created":"2018-03-08T12:10:04","date_created_gmt":"2018-03-08T12:10:04","date_modified":"2018-03-08T12:10:04","date_modified_gmt":"2018-03-08T12:10:04","discount_total":"0.00","discount_tax":"0.00","shipping_total":"150.00","shipping_tax":"0.00","cart_tax":"0.00","total":"649.00","total_tax":"0.00","prices_include_tax":False,"customer_id":12,"customer_ip_address":"103.54.99.5","customer_user_agent":"mozilla\\/5.0 (x11; linux x86_64) applewebkit\\/537.36 (khtml, like gecko) chrome\\/64.0.3282.186 safari\\/537.36","customer_note":"","billing":{"first_name":"Tony","last_name":"Stark","company":"Woocommerce","address_1":"Mumbai","address_2":"","city":"Dadar","state":"MH","postcode":"123","country":"IN","email":"tony@gmail.com","phone":"123457890"},"shipping":{"first_name":"Tony","last_name":"Stark","company":"","address_1":"Mumbai","address_2":"","city":"Dadar","state":"MH","postcode":"123","country":"IN"},"payment_method":"cod","payment_method_title":"Cash on delivery","transaction_id":"","date_paid":"","date_paid_gmt":"","date_completed":"","date_completed_gmt":"","cart_hash":"8e76b020d5790066496f244860c4703f","meta_data":[],"line_items":[{"id":80,"name":"Marvel","product_id":56,"variation_id":0,"quantity":1,"tax_class":"","subtotal":"499.00","subtotal_tax":"0.00","total":"499.00","total_tax":"0.00","taxes":[],"meta_data":[],"sku":"","price":499}],"tax_lines":[],"shipping_lines":[{"id":81,"method_title":"Flat rate","method_id":"flat_rate:1","total":"150.00","total_tax":"0.00","taxes":[],"meta_data":[{"id":623,"key":"Items","value":"Marvel × 1"}]}],"fee_lines":[],"coupon_lines":[],"refunds":[]}
|
||||||
|
|||||||
Reference in New Issue
Block a user