diff options
| author | mra (Open ERP) <mra@tinyerp.com> | 2010-03-16 16:09:34 +0530 |
|---|---|---|
| committer | mra (Open ERP) <mra@tinyerp.com> | 2010-03-16 16:09:34 +0530 |
| commit | 60f678f6e51d503c824fa94cdad59b7d1d926e6f (patch) | |
| tree | 6ce0d33e800edd056dad6c51efd619a54be680e8 /addons/project_long_term/wizard | |
| parent | 60e079dbd726094b5f0925609493b6e35e38e09a (diff) | |
| parent | 4771021d88484281eb63e988bb3c12dc6612f688 (diff) | |
[IMP] project_long_term: Clean code
bzr revid: mra@tinyerp.com-20100316103934-qvjag9zu1ue7zk2u
Diffstat (limited to 'addons/project_long_term/wizard')
| -rw-r--r-- | addons/project_long_term/wizard/compute_phases_date.py | 11 | ||||
| -rw-r--r-- | addons/project_long_term/wizard/compute_tasks_date.py | 15 |
2 files changed, 14 insertions, 12 deletions
diff --git a/addons/project_long_term/wizard/compute_phases_date.py b/addons/project_long_term/wizard/compute_phases_date.py index f684871e636..f7e49f23247 100644 --- a/addons/project_long_term/wizard/compute_phases_date.py +++ b/addons/project_long_term/wizard/compute_phases_date.py @@ -113,7 +113,8 @@ class wizard_compute_phases(wizard.interface): # Recursive call till all the next phases scheduled for phase in phase.next_phase_ids: if phase.state in ['draft','open','pending']: - self._phase_schedule(cr, uid, phase, date_start, phase.project_id.resource_calendar_id.id or False, context=context) + id_cal = phase.project_id.resource_calendar_id and phase.project_id.resource_calendar_id.id or False + self._phase_schedule(cr, uid, phase, date_start, id_cal, context=context) else: continue @@ -135,14 +136,14 @@ class wizard_compute_phases(wizard.interface): ('previous_phase_ids', '=', False) ], context=context) phase_ids.sort() - phase_objs = phase_obj.browse(cr, uid, phase_ids, context=context) - for phase in phase_objs: + phases = phase_obj.browse(cr, uid, phase_ids, context=context) + for phase in phases: start_date = phase.project_id.date_start if not phase.project_id.date_start: start_date = datetime.datetime.now().strftime("%Y-%m-%d") start_dt = datetime.datetime.strftime((datetime.datetime.strptime(start_date, "%Y-%m-%d")), "%Y-%m-%d %H:%M") - calendar_id = phase.project_id.resource_calendar_id.id - self._phase_schedule(cr, uid, phase, start_dt, calendar_id or False, context=context) + calendar_id = phase.project_id.resource_calendar_id and phase.project_id.resource_calendar_id.id or False + self._phase_schedule(cr, uid, phase, start_dt, calendar_id, context=context) return {} def _open_phases_list(self, cr, uid, data, context): diff --git a/addons/project_long_term/wizard/compute_tasks_date.py b/addons/project_long_term/wizard/compute_tasks_date.py index 1187980057b..17a2b90b50b 100644 --- a/addons/project_long_term/wizard/compute_tasks_date.py +++ b/addons/project_long_term/wizard/compute_tasks_date.py @@ -61,8 +61,8 @@ class wizard_compute_tasks(wizard.interface): ]) if task_ids: task_ids.sort() - task_objs = task_pool.browse(cr, uid, task_ids, context=context) - calendar_id = project.resource_calendar_id.id + tasks = task_pool.browse(cr, uid, task_ids, context=context) + calendar_id = project.resource_calendar_id and project.resource_calendar_id.id or False start_date = project.date_start if not project.date_start: start_date = datetime.datetime.now().strftime("%Y-%m-%d") @@ -74,9 +74,10 @@ class wizard_compute_tasks(wizard.interface): time_efficiency = 1.0 resource_id = resource_obj.search(cr, uid, [('user_id', '=', user.id)]) if resource_id: - resource = resource_obj.browse(cr, uid, resource_id, context=context)[0] - leaves = wkcal.compute_leaves(cr, uid, calendar_id or False , resource_id, resource.calendar_id.id) - time_efficiency = resource.time_efficiency +# resource = resource_obj.browse(cr, uid, resource_id, context=context)[0] + resource = resource_obj.read(cr, uid, resource_id, ['calendar_id','time_efficiency'], context=context)[0] + leaves = wkcal.compute_leaves(cr, uid, calendar_id , resource_id, resource.get('calendar_id')[0]) + time_efficiency = resource.get('time_efficiency') resources.append(classobj(str(user.name), (Resource,), {'__doc__': user.name, '__name__': user.name, 'vacation': tuple(leaves), @@ -111,7 +112,7 @@ class wizard_compute_tasks(wizard.interface): vacation = tuple(wkcal.compute_leaves(cr, uid, calendar_id)) # Dynamic Creation of tasks i = 0 - for each_task in task_objs: + for each_task in tasks: hours = str(each_task.planned_hours / each_task.occupation_rate)+ 'H' if each_task.priority in priority_dict.keys(): priorty = priority_dict[each_task.priority] @@ -135,7 +136,7 @@ class wizard_compute_tasks(wizard.interface): ctx = context.copy() ctx.update({'scheduler': True}) user_id = user_obj.search(cr, uid, [('name', '=', t.booked_resource[0].__name__)]) - task_pool.write(cr, uid, [task_objs[loop_no-1].id], {'date_start': s_date.strftime('%Y-%m-%d %H:%M:%S'), + task_pool.write(cr, uid, [tasks[loop_no-1].id], {'date_start': s_date.strftime('%Y-%m-%d %H:%M:%S'), 'date_deadline': e_date.strftime('%Y-%m-%d %H:%M:%S'), 'user_id': user_id[0]}, context=ctx) |
