[IMP]:Tasks scheduling with priority assigned

bzr revid: rvo@tinyerp.co.in-20100211112630-gsnzato64kj1mgrg
This commit is contained in:
Rvo (Open ERP) 2010-02-11 16:56:30 +05:30
parent 34cbb6821f
commit 379049f637
2 changed files with 16 additions and 21 deletions

View File

@ -160,25 +160,18 @@ class wizard_compute_tasks(wizard.interface):
leaves = leaves_resource(cr,uid,resource_id)
resource_objs.append(classobj(str(resource[no].name),(Resource,),{'__doc__':resource[no].name,'__name__':resource[no].name,'vacation':tuple(leaves)}))
# To create dynamic no of tasks
def tasks(j,eff):
def task():
"""
task is a dynamic method!
"""
effort = eff
task.__doc__ = "TaskNO%d" %j
task.__name__ = "task%d" %j
return task
priority_dict = {'0':1000,'1':800,'2':500,'3':300,'4':100}
# To create dynamic no of tasks with the resource specified
def tasks_resource(j,eff,obj):
def tasks_resource(j,eff,priorty = 500,obj=None):
def task():
"""
task is a dynamic method!
"""
effort = eff
resource = obj
if obj:
resource = obj
priority = priorty
task.__doc__ = "TaskNO%d" %j
task.__name__ = "task%d" %j
return task
@ -188,6 +181,7 @@ class wizard_compute_tasks(wizard.interface):
title = project.name
start = date_start
resource = reduce(operator.or_,resource_objs)
# If project has calendar
if wktime_cal:
working_days = wktime_cal
@ -196,12 +190,14 @@ class wizard_compute_tasks(wizard.interface):
# Dynamic Creation of tasks
for i in range(len(task_obj)):
hours = str(task_obj[i].remaining_hours / task_obj[i].occupation_rate)+ 'H'
if task_obj[i].priority in priority_dict.keys():
priorty = priority_dict[task_obj[i].priority]
if task_obj[i].user_id:
for resource_object in resource_objs:
for resource_object in resource_objs:
if resource_object.__name__ == task_obj[i].user_id.name:
task = tasks_resource(i,hours,resource_object)
task = tasks_resource(i,hours,priorty,resource_object)
else:
task = tasks(i,hours)
task = tasks_resource(i,hours,priorty)
project = BalancedProject(Project)
task_no = len(task_obj)
@ -212,6 +208,7 @@ class wizard_compute_tasks(wizard.interface):
s_date = t.start.to_datetime()
e_date = t.end.to_datetime()
if loop_no != 0:
print 's_date,e_date>>>>',s_date,e_date,t.name,t.booked_resource,t.priority
user_id = user_pool.search(cr,uid,[('name','=',t.booked_resource[0].__name__)])
task_pool.write(cr,uid,[task_obj[loop_no - 1].id],{'date_start':s_date,'date_end':e_date,'user_id':user_id[0]})
loop_no = task_no + 1

View File

@ -1941,7 +1941,7 @@ class Task(object):
func.task_func = instrumented # will be used in the gui
self._function = instrumented
self.name = func.func_name
self.name = name
self.up = parent
self.children = []
self._sources = {} # all tasks, I am linked to
@ -2548,7 +2548,6 @@ class Task(object):
#@+node:Setting methods
#@+node:_set_attrib
def _set_attrib(self, name, value):
if value is _NEVER_USED_: return
try:
@ -2564,11 +2563,11 @@ class Task(object):
#@ << add child task >>
#@+node:<< add child task >>
try:
task = self.__dict__[name]
task = self.__dict__[value.func_name]
except KeyError:
task = Task(value, name, self, len(self.children) + 1)
task = Task(value, value.func_name, self, len(self.children) + 1)
self.children.append(task)
setattr(self, task.name, task)
setattr(self, value.func_name, task)
return
#@nonl
#@-node:<< add child task >>
@ -3698,7 +3697,6 @@ class AdjustedProject(_AllocationPoject):
for t in balancing_list:
src = base.get_task(t.path)
if src.end <= now and src.complete == 100:
#@ << copy the attribs of complete tasks >>
#@+node:<< copy the attribs of complete tasks >>