[FIX] project_long_term: Fix yaml tests, specify resourceusers and
If a user is not associated with a resource of the project, compute his task/phase as if no user had been specified. bzr revid: hmo@tinyerp.com-20100901060717-o2lfueq3boatc4h7
This commit is contained in:
parent
e08ada7432
commit
30189fb7e8
|
@ -41,7 +41,7 @@
|
|||
state: draft
|
||||
phase_id: project_phase_phase0
|
||||
project_id: project_project_project0
|
||||
|
||||
user_id: project_long_term.res_users_userdeveloper0
|
||||
|
||||
-
|
||||
Create the phase task 'Develop GUI for Modules Configuration'
|
||||
|
@ -53,7 +53,7 @@
|
|||
state: draft
|
||||
phase_id: project_phase_phase0
|
||||
project_id: project_project_project0
|
||||
|
||||
user_id: project_long_term.res_users_userdeveloper0
|
||||
-
|
||||
Create the phase task 'Develop GUI for OpenERP Synchronisation'
|
||||
-
|
||||
|
@ -64,8 +64,7 @@
|
|||
state: draft
|
||||
phase_id: project_phase_phase0
|
||||
project_id: project_project_project0
|
||||
|
||||
|
||||
user_id: project_long_term.res_users_userdeveloper0
|
||||
-
|
||||
Create the phase task 'Develop required Menus'
|
||||
-
|
||||
|
@ -76,16 +75,19 @@
|
|||
state: draft
|
||||
phase_id: project_phase_phase0
|
||||
project_id: project_project_project0
|
||||
|
||||
user_id: project_long_term.res_users_userdesign0
|
||||
|
||||
-
|
||||
Schedule phase tasks
|
||||
-
|
||||
!python {model: project.schedule.tasks}: |
|
||||
self.compute_date(cr, uid, {"lang": "en_US",
|
||||
"active_model": "project.phase", "active_ids": [ref("project_phase_phase0")],
|
||||
"tz": False, "record_id": 138, "project_id": ref("project_project_project0"), "active_id": ref("project_phase_phase0"),
|
||||
})
|
||||
res = self.compute_date(cr, uid, {"lang": "en_US", "tz": False,
|
||||
"active_id": ref("project_phase_phase0"),
|
||||
# rest may be obsolete:
|
||||
# "active_model": "project.phase", "active_ids": [ref("project_phase_phase0")],
|
||||
# "record_id": 138, "project_id": ref("project_project_project0"),
|
||||
})
|
||||
print res
|
||||
|
||||
-
|
||||
Check if tasks scheduled, check that either of task's start_date, end_date and user_id is not null
|
||||
|
@ -93,5 +95,6 @@
|
|||
!python {model: project.phase}: |
|
||||
phase=self.browse(cr, uid, [ref("project_phase_phase0")])[0]
|
||||
for task in phase.task_ids:
|
||||
if (not task.user_id) or (not task.date_start) or (not task.date_end):
|
||||
raise AssertionError("Phase Tasks not scheduled")
|
||||
if (not task.user_id) or (not task.date_start) or (not task.date_end):
|
||||
raise AssertionError("Phase Tasks not scheduled: %d uid=%r start=%r end=%r" % \
|
||||
(task.id, task.user_id, task.date_start, task.date_end))
|
|
@ -42,7 +42,7 @@
|
|||
state: draft
|
||||
phase_id: project_phase_phase1
|
||||
project_id: project_project_project1
|
||||
|
||||
user_id: project_long_term.res_users_userdeveloper0
|
||||
|
||||
-
|
||||
Create the phase task 'Develop GUI for Modules Configuration'
|
||||
|
@ -54,7 +54,7 @@
|
|||
state: draft
|
||||
phase_id: project_phase_phase1
|
||||
project_id: project_project_project1
|
||||
|
||||
user_id: project_long_term.res_users_userdeveloper0
|
||||
-
|
||||
Create the phase task 'Develop GUI for OpenERP Synchronisation'
|
||||
-
|
||||
|
@ -89,10 +89,10 @@
|
|||
Schedule tasks
|
||||
-
|
||||
!python {model: project.compute.tasks}: |
|
||||
self.compute_date(cr, uid, [ref("project_compute_tasks_0")], {"lang": "en_US",
|
||||
"active_model": "ir.ui.menu", "active_ids": [ref("project_long_term.menu_compute_tasks")],
|
||||
"tz": False, "record_id": 138, "project_id": ref("project_project_project1"), "active_id": ref("project_long_term.menu_compute_tasks"),
|
||||
})
|
||||
self.compute_date(cr, uid, [ref("project_compute_tasks_0")], {"lang": "en_US", "tz": False,
|
||||
"active_id": ref("project_long_term.menu_compute_tasks"),
|
||||
"active_model": "ir.ui.menu", "active_ids": [ref("project_long_term.menu_compute_tasks")],
|
||||
})
|
||||
|
||||
-
|
||||
Check if tasks scheduled, check that either of task's start_date, end_date and user_id is not null
|
||||
|
|
|
@ -113,12 +113,13 @@ class project_compute_tasks(osv.osv_memory):
|
|||
hours = str(each_task.planned_hours )+ 'H'
|
||||
if each_task.priority in priority_dict.keys():
|
||||
priorty = priority_dict[each_task.priority]
|
||||
rcre = False
|
||||
if each_task.user_id:
|
||||
for resrce in resources:
|
||||
if resrce.__name__ == each_task.user_id.name: # check me!!
|
||||
task = create_tasks(i, hours, priorty, resrce)
|
||||
else:
|
||||
task = create_tasks(i, hours, priorty)
|
||||
rcre = resrce
|
||||
break
|
||||
task = create_tasks(i, hours, priorty, rcre)
|
||||
i += 1
|
||||
|
||||
project = BalancedProject(Project)
|
||||
|
|
|
@ -73,8 +73,6 @@ class project_schedule_task(osv.osv_memory):
|
|||
return resource_objs
|
||||
|
||||
def compute_date(self, cr, uid, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
"""
|
||||
Schedule the tasks according to resource available and priority.
|
||||
"""
|
||||
|
@ -84,7 +82,8 @@ class project_schedule_task(osv.osv_memory):
|
|||
user_obj = self.pool.get('res.users')
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
# It makes no sense to continue on empty context
|
||||
return { 'warning': _("You must select some project phase to compute on")}
|
||||
|
||||
if not 'active_id' in context:
|
||||
return {}
|
||||
|
@ -135,15 +134,18 @@ class project_schedule_task(osv.osv_memory):
|
|||
hours = str(each_task.planned_hours )+ 'H'
|
||||
if each_task.priority in priority_dict.keys():
|
||||
priorty = priority_dict[each_task.priority]
|
||||
resc = False
|
||||
if each_task.user_id:
|
||||
for resrce in resources:
|
||||
for resrce in resources:
|
||||
if resrce.__name__ == each_task.user_id.name:
|
||||
task = create_tasks(i, hours, priorty, resrce)
|
||||
else:
|
||||
task = create_tasks(i, hours, priorty)
|
||||
resc = resrce
|
||||
break
|
||||
|
||||
task = create_tasks(i, hours, priorty, resc)
|
||||
i += 1
|
||||
|
||||
project = BalancedProject(Project)
|
||||
|
||||
loop_no = 0
|
||||
# Write back the computed dates
|
||||
for t in project:
|
||||
|
@ -160,6 +162,8 @@ class project_schedule_task(osv.osv_memory):
|
|||
}, context=ctx)
|
||||
|
||||
loop_no += 1
|
||||
else:
|
||||
return {"warning": _("No tasks to compute for this phase") }
|
||||
return {}
|
||||
|
||||
project_schedule_task()
|
||||
|
|
Loading…
Reference in New Issue