def update_dependent_tasks(my, top=True): '''for purposes of dependent tasks''' if top: Task.tasks_updated = [] Task.tasks_updated.append(my.get_id()) # get the dependent tasks tasks = my.get_dependent_tasks() bid_start_date = my.get_value("bid_start_date") bid_end_date = my.get_value("bid_end_date") bid_duration_unit = ProdSetting.get_value_by_key("bid_duration_unit") if not bid_duration_unit: bid_duration_unit = 'hour' # if there is no end date specified, return if not bid_end_date: bid_duration = my.get_value("bid_duration") if bid_duration and bid_start_date: date = Date(db=bid_start_date) bid_duration = float(bid_duration) if bid_duration_unit == 'minute': date.add_minutes(bid_duration) else: date.add_hours(bid_duration) bid_end_date = date.get_db_time() else: return for task in tasks: # prevent circular dependency if for some reason they occur. if task.get_id() in Task.tasks_updated: Environment.add_warning("Circular dependency", "Circular dependency with task '%s'" % task.get_id() ) continue Task.tasks_updated.append(my.get_id()) # if the dependency is fixed, update the d #mode = task.get_value("mode") mode = "depend" # put the start date as the end date if mode == "depend": # add one day to the end date to get the start date date = Date(db=bid_end_date) date.add_days(1) bid_start_date = date.get_db_time() task.set_value("bid_start_date", bid_start_date ) # check if there is a duration in hours to this date bid_duration = task.get_value("bid_duration") if bid_duration: bid_duration = int(bid_duration) date = Date(db=bid_start_date) if bid_duration_unit == 'minute': date.add_minutes(bid_duration) else: date.add_hours(bid_duration) bid_end_date = date.get_db_time() task.set_value("bid_end_date", bid_end_date) task.commit() task.update_dependent_tasks(False)