fix(Task): Do not create/schedule task after project end (#19184)

* fix: do not create/schedule task after project end

* fix: check difference between dates

* fix: check project date

* fix: task creation

* fix: tests
This commit is contained in:
Himanshu
2019-11-14 10:11:25 +05:30
committed by Nabin Hait
parent 73616d6b33
commit 5503b6cff5
2 changed files with 29 additions and 10 deletions

View File

@@ -51,27 +51,25 @@ class CropCycle(Document):
self.create_task(disease_doc.treatment_task, self.name, start_date)
def create_project(self, period, crop_tasks):
project = frappe.new_doc("Project")
project.update({
project = frappe.get_doc({
"doctype": "Project",
"project_name": self.title,
"expected_start_date": self.start_date,
"expected_end_date": add_days(self.start_date, period - 1)
})
project.insert()
}).insert()
return project.name
def create_task(self, crop_tasks, project_name, start_date):
for crop_task in crop_tasks:
task = frappe.new_doc("Task")
task.update({
frappe.get_doc({
"doctype": "Task",
"subject": crop_task.get("task_name"),
"priority": crop_task.get("priority"),
"project": project_name,
"exp_start_date": add_days(start_date, crop_task.get("start_day") - 1),
"exp_end_date": add_days(start_date, crop_task.get("end_day") - 1)
})
task.insert()
}).insert()
def reload_linked_analysis(self):
linked_doctypes = ['Soil Texture', 'Soil Analysis', 'Plant Analysis']