Dependent task dates gets updated with parent dates

This commit is contained in:
Kanchan Chauhan 2017-02-27 12:00:25 +05:30
parent 72c7e73ce0
commit e76685d925
5 changed files with 77 additions and 20 deletions

View File

@ -6,6 +6,18 @@ frappe.provide("erpnext.projects");
cur_frm.add_fetch("project", "company", "company");
frappe.ui.form.on("Task", {
onload: function(frm) {
frm.set_query("task", "depends_on", function() {
var filters = {
name: ["!=", frm.doc.name]
};
if(frm.doc.project) filters["project"] = frm.doc.project;
return {
filters: filters
};
})
},
refresh: function(frm) {
var doc = frm.doc;
if(doc.__islocal) {
@ -14,7 +26,6 @@ frappe.ui.form.on("Task", {
}
}
if(!doc.__islocal) {
if(frappe.model.can_read("Timesheet")) {
frm.add_custom_button(__("Timesheet"), function() {
@ -67,12 +78,5 @@ frappe.ui.form.on("Task", {
});
cur_frm.fields_dict['depends_on'].grid.get_field('task').get_query = function(doc) {
if(doc.project) {
return {
filters: {'project': doc.project}
}
}
}
cur_frm.add_fetch('task', 'subject', 'subject');
cur_frm.add_fetch('task', 'project', 'project');

View File

@ -496,7 +496,7 @@
"collapsible": 0,
"columns": 0,
"fieldname": "depends_on_tasks",
"fieldtype": "Read Only",
"fieldtype": "Data",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@ -504,14 +504,14 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "depends_on_tasks",
"label": "Depends on Tasks",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
@ -976,7 +976,7 @@
"istable": 0,
"max_attachments": 5,
"menu_index": 0,
"modified": "2017-02-17 17:24:21.786060",
"modified": "2017-02-24 01:47:05.438887",
"modified_by": "Administrator",
"module": "Projects",
"name": "Task",

View File

@ -105,16 +105,18 @@ class Task(Document):
def reschedule_dependent_tasks(self):
end_date = self.exp_end_date or self.act_end_date
if end_date:
for task_name in frappe.db.sql("select name from `tabTask` as parent where %s in \
(select task from `tabTask Depends On` as child where parent.name = child.parent )", self.name, as_dict=1):
for task_name in frappe.db.sql("""select name from `tabTask` as parent where parent.project = %(project)s and parent.name in \
(select parent from `tabTask Depends On` as child where child.task = %(task)s and child.project = %(project)s)""",
{'project': self.project, 'task':self.name }, as_dict=1):
task = frappe.get_doc("Task", task_name.name)
if task.exp_start_date and task.exp_end_date and task.exp_start_date < getdate(end_date) and task.status == "Open" :
if task.exp_start_date and task.exp_end_date and task.exp_start_date < getdate(end_date) and task.status == "Open":
task_duration = date_diff(task.exp_end_date, task.exp_start_date)
task.exp_start_date = add_days(end_date, 1)
task.exp_end_date = add_days(task.exp_start_date, task_duration)
task.flags.ignore_recursion_check = True
task.save()
def has_webform_permission(doc):
project_user = frappe.db.get_value("Project User", {"parent": doc.project, "user":frappe.session.user} , "user")
if project_user:

View File

@ -16,6 +16,7 @@ class TestTask(unittest.TestCase):
task1.update({
"status": "Open",
"subject": "_Test Task 1",
"project": "_Test Project",
"exp_start_date": "2015-1-1",
"exp_end_date": "2015-1-10"
})
@ -25,6 +26,7 @@ class TestTask(unittest.TestCase):
task2.update({
"status": "Open",
"subject": "_Test Task 2",
"project": "_Test Project",
"exp_start_date": "2015-1-11",
"exp_end_date": "2015-1-15",
"depends_on":[
@ -39,6 +41,7 @@ class TestTask(unittest.TestCase):
task3.update({
"status": "Open",
"subject": "_Test Task 2",
"project": "_Test Project",
"exp_start_date": "2015-1-11",
"exp_end_date": "2015-1-15",
"depends_on":[
@ -80,6 +83,7 @@ class TestTask(unittest.TestCase):
task1.update({
"status": "Open",
"subject": "_Test Task 1",
"project": "_Test Project",
"exp_start_date": "2015-1-1",
"exp_end_date": "2015-1-10"
})
@ -89,11 +93,13 @@ class TestTask(unittest.TestCase):
task2.update({
"status": "Open",
"subject": "_Test Task 2",
"project": "_Test Project",
"exp_start_date": "2015-1-11",
"exp_end_date": "2015-1-15",
"depends_on":[
{
"task": task1.name
"task": task1.name,
"project": "_Test Project"
}
]
})
@ -103,11 +109,13 @@ class TestTask(unittest.TestCase):
task3.update({
"status": "Open",
"subject": "_Test Task 3",
"project": "_Test Project",
"exp_start_date": "2015-1-16",
"exp_end_date": "2015-1-18",
"depends_on":[
{
"task": task2.name
"task": task2.name,
"project": "_Test Project"
}
]
})

View File

@ -14,13 +14,16 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "task",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Task",
"length": 0,
"no_copy": 0,
@ -30,6 +33,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@ -40,13 +44,16 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_2",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@ -54,6 +61,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@ -64,13 +72,16 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "subject",
"fieldtype": "Text",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Subject",
"length": 0,
"no_copy": 0,
@ -80,6 +91,36 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "project",
"fieldtype": "Text",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Project",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@ -97,7 +138,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2016-07-11 03:28:09.329158",
"modified": "2017-02-24 04:56:04.862502",
"modified_by": "Administrator",
"module": "Projects",
"name": "Task Depends On",
@ -107,7 +148,9 @@
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 0,
"track_seen": 0
}