fixes in Pull request
This commit is contained in:
parent
c8f0c25088
commit
350943128a
@ -29,7 +29,7 @@ class Task(Document):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_dates()
|
self.validate_dates()
|
||||||
self.validate_depends_on()
|
self.validate_depends_on()
|
||||||
self.reschedule_depending_task()
|
self.reschedule_dependent_task()
|
||||||
|
|
||||||
def validate_dates(self):
|
def validate_dates(self):
|
||||||
if self.exp_start_date and self.exp_end_date and getdate(self.exp_start_date) > getdate(self.exp_end_date):
|
if self.exp_start_date and self.exp_end_date and getdate(self.exp_start_date) > getdate(self.exp_end_date):
|
||||||
@ -87,14 +87,16 @@ class Task(Document):
|
|||||||
task_list.append(task)
|
task_list.append(task)
|
||||||
return frappe.db.get_value("Task", task, "depends_on")
|
return frappe.db.get_value("Task", task, "depends_on")
|
||||||
|
|
||||||
def reschedule_depending_task(self):
|
def reschedule_dependent_task(self):
|
||||||
for task_name in frappe.db.sql("select name from `tabTask` where depends_on = %s", self.name, as_dict=1):
|
end_date = self.exp_end_date or self.act_end_date
|
||||||
task = frappe.get_doc("Task", task_name.name)
|
if end_date:
|
||||||
if task.exp_start_date and task.exp_end_date and (self.exp_end_date or self.act_end_date):
|
for task_name in frappe.db.sql("select name from `tabTask` where depends_on = %s", self.name, as_dict=1):
|
||||||
task_duration = date_diff(task.exp_end_date, task.exp_start_date)
|
task = frappe.get_doc("Task", task_name.name)
|
||||||
task.exp_start_date = add_days(self.act_end_date if self.act_end_date else self.exp_end_date, 1)
|
if task.exp_start_date and task.exp_end_date and task.exp_start_date < end_date and task.status == "Open" :
|
||||||
task.exp_end_date = add_days(task.exp_start_date, task_duration)
|
task_duration = date_diff(task.exp_end_date, task.exp_start_date)
|
||||||
task.save()
|
task.exp_start_date = add_days(end_date, 1)
|
||||||
|
task.exp_end_date = add_days(task.exp_start_date, task_duration)
|
||||||
|
task.save()
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_events(start, end, filters=None):
|
def get_events(start, end, filters=None):
|
||||||
|
@ -39,7 +39,7 @@ class TestTask(unittest.TestCase):
|
|||||||
})
|
})
|
||||||
self.assertRaises(CircularReferenceError, task1.save)
|
self.assertRaises(CircularReferenceError, task1.save)
|
||||||
|
|
||||||
def test_reschedule_depending_task(self):
|
def test_reschedule_dependent_task(self):
|
||||||
task1 = frappe.new_doc('Task')
|
task1 = frappe.new_doc('Task')
|
||||||
task1.update({
|
task1.update({
|
||||||
"status": "Open",
|
"status": "Open",
|
||||||
|
Loading…
Reference in New Issue
Block a user