From 8baf16f25e2f0c158f75527105ba1a712677e0f8 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Sat, 12 Jun 2010 18:21:54 +0200 Subject: [IMP] access rights. Remove bad stuff on point of sale bzr revid: fp@tinyerp.com-20100612162154-f9dgju8wsmn79gq0 --- addons/project_long_term/project_long_term.py | 108 -------------------------- 1 file changed, 108 deletions(-) (limited to 'addons/project_long_term/project_long_term.py') diff --git a/addons/project_long_term/project_long_term.py b/addons/project_long_term/project_long_term.py index 212af8a30dc..57fbd1abb5f 100644 --- a/addons/project_long_term/project_long_term.py +++ b/addons/project_long_term/project_long_term.py @@ -256,115 +256,7 @@ class task(osv.osv): _inherit = "project.task" _columns = { 'phase_id': fields.many2one('project.phase', 'Project Phase'), - 'occupation_rate': fields.float('Occupation Rate', help='The occupation rate fields indicates how much of his time a user is working on a task. A 100% occupation rate means the user works full time on the tasks. The ending date of a task is computed like this: Starting Date + Duration / Occupation Rate.'), - 'planned_hours': fields.float('Planned Hours', required=True, help='Estimated time to do the task, usually set by the project manager when the task is in draft state.'), } - _defaults = { - 'occupation_rate': '1' - } - - def onchange_planned(self, cr, uid, ids, project, user_id=False, planned=0.0, effective=0.0, date_start=None, occupation_rate=0.0): - result = {} - resource = False - resource_obj = self.pool.get('resource.resource') - project_pool = self.pool.get('project.project') - resource_calendar = self.pool.get('resource.calendar') - if not project: - return {'value' : result} - if date_start: - hrs = float(planned / float(occupation_rate)) - calendar_id = project_pool.browse(cr, uid, project).resource_calendar_id.id - dt_start = mx.DateTime.strptime(date_start, '%Y-%m-%d %H:%M:%S') - resource_id = resource_obj.search(cr, uid, [('user_id','=',user_id)]) - if resource_id: - resource_data = resource_obj.browse(cr, uid, resource_id)[0] - resource = resource_data.id - hrs = planned / (float(occupation_rate) * resource_data.time_efficiency) - if resource_data.calendar_id.id: - calendar_id = resource_data.calendar_id.id - work_times = resource_calendar.interval_get(cr, uid, calendar_id, dt_start, hrs or 0.0, resource or False) - if work_times: - result['date_end'] = work_times[-1][1].strftime('%Y-%m-%d %H:%M:%S') - result['remaining_hours'] = planned - effective - return {'value' : result} - - def _check_date_start(self, cr, uid, task, date_end, context={}): - """ - Check And Compute date_end of task if change in date_start < older time. - """ - resource_calendar_obj = self.pool.get('resource.calendar') - resource_obj = self.pool.get('resource.resource') - calendar_id = task.project_id.resource_calendar_id and task.project_id.resource_calendar_id.id or False - hours = task.planned_hours / task.occupation_rate - resource_id = resource_obj.search(cr, uid, [('user_id', '=', task.user_id.id)], context=context) - if resource_id: - resource = resource_obj.browse(cr, uid, resource_id[0], context=context) - if resource.calendar_id.id: - calendar_id = resource.calendar_id and resource.calendar_id.id or False - hours = task.planned_hours / (float(task.occupation_rate) * resource.time_efficiency) - work_times = resource_calendar_obj.interval_min_get(cr, uid, calendar_id, date_end, hours or 0.0, resource_id and resource_id[0] or False) - dt_start = work_times[0][0].strftime('%Y-%m-%d %H:%M:%S') - self.write(cr, uid, [task.id], {'date_start' : dt_start,'date_end' : date_end.strftime('%Y-%m-%d %H:%M:%S')}) - - def _check_date_end(self, cr, uid, task, date_start, context={}): - """ - Check And Compute date_end of task if change in date_end > older time. - """ - resource_calendar_obj = self.pool.get('resource.calendar') - resource_obj = self.pool.get('resource.resource') - calendar_id = task.project_id.resource_calendar_id and task.project_id.resource_calendar_id.id or False - hours = task.planned_hours / task.occupation_rate - resource_id = resource_obj.search(cr,uid,[('user_id', '=', task.user_id.id)], context=context) - if resource_id: - resource = resource_obj.browse(cr, uid, resource_id[0], context=context) - if resource.calendar_id.id: - calendar_id = resource.calendar_id and resource.calendar_id.id or False - hours = task.planned_hours / (float(task.occupation_rate) * resource.time_efficiency) - work_times = resource_calendar_obj.interval_get(cr, uid, calendar_id, date_start, hours or 0.0, resource_id and resource_id[0] or False) - dt_end = work_times[-1][1].strftime('%Y-%m-%d %H:%M:%S') - self.write(cr, uid, [task.id], {'date_start': date_start.strftime('%Y-%m-%d %H:%M:%S'),'date_end' : dt_end}, context=context) - - def write(self, cr, uid, ids, vals, context={}): - resource_calendar_obj = self.pool.get('resource.calendar') - resource_obj = self.pool.get('resource.resource') - if not context: - context = {} - if context.get('scheduler',False): - return super(task, self).write(cr, uid, ids, vals, context=context) - - # Consider calendar and efficiency if the task is performed by a resource - # otherwise consider the project's working calendar - task_id = ids - if isinstance(ids, list): - task_id = ids[0] - task_rec = self.browse(cr, uid, task_id, context=context) - calendar_id = task_rec.project_id.resource_calendar_id and task_rec.project_id.resource_calendar_id.id or False - hrs = task_rec.planned_hours / task_rec.occupation_rate - resource_id = resource_obj.search(cr, uid, [('user_id', '=', task_rec.user_id.id)], context=context) - if resource_id: - resource = resource_obj.browse(cr, uid, resource_id[0], context=context) - if resource.calendar_id.id: - calendar_id = resource.calendar_id and resource.calendar_id.id or False - hrs = task_rec.planned_hours / (float(task_rec.occupation_rate) * resource.time_efficiency) - - # Change the date_start and date_end - # for previous and next tasks respectively based on valid condition - if vals.get('date_start', False) and vals['date_start'] < task_rec.date_start: - dt_start = mx.DateTime.strptime(vals['date_start'], '%Y-%m-%d %H:%M:%S') - work_times = resource_calendar_obj.interval_get(cr, uid, calendar_id, dt_start, hrs or 0.0, resource.id or False) - if work_times: - vals['date_end'] = work_times[-1][1].strftime('%Y-%m-%d %H:%M:%S') - for prv_task in task_rec.parent_ids: - self._check_date_start(cr, uid, prv_task, dt_start) - if vals.get('date_end', False) and vals['date_end'] > task_rec.date_end: - dt_end = mx.DateTime.strptime(vals['date_end'], '%Y-%m-%d %H:%M:%S') - work_times = resource_calendar_obj.interval_min_get(cr, uid, calendar_id, dt_end, hrs or 0.0, resource.id or False) - if work_times: - vals['date_start'] = work_times[0][0].strftime('%Y-%m-%d %H:%M:%S') - for next_task in task_rec.child_ids: - self._check_date_end(cr, uid, next_task, dt_end) - - return super(task, self).write(cr, uid, ids, vals, context=context) task() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -- cgit v1.2.3