This commit is contained in:
Anurag Mishra 2019-01-04 10:54:05 +05:30
parent 4c8c50e464
commit f2b29a0488
2 changed files with 8 additions and 7 deletions

View File

@ -12,7 +12,7 @@ from frappe.utils.nestedset import NestedSet
class CircularReferenceError(frappe.ValidationError): pass
class EndDateConnotGreaterThanProjecteEndDateError(frappe.ValidationError): pass
class EndDateCannotGreaterThanProjecteEndDateError(frappe.ValidationError): pass
class Task(NestedSet):
nsm_parent_field = 'parent_task'
@ -45,10 +45,11 @@ class Task(NestedSet):
frappe.throw(_("'Actual Start Date' can not be greater than 'Actual End Date'"))
if(self.project):
doc = frappe.get_doc("Project", self.project)
if self.exp_end_date and doc.expected_end_date and getdate(self.exp_end_date) > getdate(doc.expected_end_date) :
frappe.msgprint(_("Expected end date cannot be after Project: <b>'{0}'</b> Expected end date").format(doc.name))
raise EndDateConnotGreaterThanProjecteEndDateError
if frappe.db.exists("Project", self.project):
doc = frappe.get_doc("Project", self.project)
if self.exp_end_date and doc.expected_end_date and getdate(self.exp_end_date) > getdate(doc.expected_end_date) :
frappe.msgprint(_("Expected end date cannot be after Project: <b>'{0}'</b> Expected end date").format(doc.name))
raise EndDateCannotGreaterThanProjecteEndDateError
def validate_status(self):
if self.status!=self.get_db_value("status") and self.status == "Closed":

View File

@ -5,7 +5,7 @@ import frappe
import unittest
from frappe.utils import getdate, nowdate, add_days
from erpnext.projects.doctype.task.task import CircularReferenceError, EndDateConnotGreaterThanProjecteEndDateError
from erpnext.projects.doctype.task.task import CircularReferenceError, EndDateCannotGreaterThanProjecteEndDateError
class TestTask(unittest.TestCase):
def test_circular_reference(self):
@ -102,7 +102,7 @@ class TestTask(unittest.TestCase):
pro = frappe.get_doc("Project", task_end.project)
pro.expected_end_date = add_days(nowdate(), 40)
pro.save()
self.assertRaises(EndDateConnotGreaterThanProjecteEndDateError, task_end.save)
self.assertRaises(EndDateCannotGreaterThanProjecteEndDateError, task_end.save)