[minor] fix date comparisons

This commit is contained in:
Rushabh Mehta 2016-10-18 14:44:01 +05:30
parent df01b5770b
commit bdc8a88b4d

View File

@ -5,7 +5,7 @@
from __future__ import unicode_literals
import frappe
from frappe import msgprint, _
from frappe.utils import get_datetime, get_datetime_str
from frappe.utils import get_datetime
from frappe.model.document import Document
class AcademicTerm(Document):
@ -24,10 +24,10 @@ class AcademicTerm(Document):
"""Check that the start of the term is not before the start of the academic year and end of term is not after
the end of the academic year"""
year = frappe.get_doc("Academic Year",self.academic_year)
if self.term_start_date and get_datetime_str(year.year_start_date) and (self.term_start_date < get_datetime_str(year.year_start_date)):
if self.term_start_date and get_datetime(year.year_start_date) and (self.term_start_date < get_datetime(year.year_start_date)):
frappe.throw(_("The Term Start Date cannot be earlier than the Year Start Date of the Academic Year to which the term is linked (Academic Year {}). Please correct the dates and try again.").format(self.academic_year))
if self.term_end_date and get_datetime_str(year.year_end_date) and (self.term_end_date > get_datetime_str(year.year_end_date)):
if self.term_end_date and get_datetime_(year.year_end_date) and (self.term_end_date > get_datetime(year.year_end_date)):
frappe.throw(_("The Term End Date cannot be later than the Year End Date of the Academic Year to which the term is linked (Academic Year {}). Please correct the dates and try again.").format(self.academic_year))