summaryrefslogtreecommitdiff
path: root/addons/project_long_term/project_long_term.py
diff options
context:
space:
mode:
authorHarry (OpenERP) <hmo@tinyerp.com>2010-12-30 16:18:25 +0530
committerHarry (OpenERP) <hmo@tinyerp.com>2010-12-30 16:18:25 +0530
commit224253a44dffed237d4c8a531dae029cb6143118 (patch)
tree9eccea3e4657f0f73e6a1818349a88d62451b5ff /addons/project_long_term/project_long_term.py
parent25956186b97c2a7a7d628485d891d1d490476398 (diff)
[FIX] project_long_term: fix regression
bzr revid: hmo@tinyerp.com-20101230104825-kuf2gj3pgoyhqif8
Diffstat (limited to 'addons/project_long_term/project_long_term.py')
-rw-r--r--addons/project_long_term/project_long_term.py50
1 files changed, 1 insertions, 49 deletions
diff --git a/addons/project_long_term/project_long_term.py b/addons/project_long_term/project_long_term.py
index d2bc48df375..ad972b89dad 100644
--- a/addons/project_long_term/project_long_term.py
+++ b/addons/project_long_term/project_long_term.py
@@ -192,55 +192,6 @@ class project_phase(osv.osv):
dt_end = work_times[-1][1].strftime('%Y-%m-%d')
self.write(cr, uid, [phase.id], {'date_start': date_start.strftime('%Y-%m-%d'), 'date_end': dt_end}, context=context)
- def write(self, cr, uid, ids, vals, context=None):
- resource_calendar_obj = self.pool.get('resource.calendar')
- resource_obj = self.pool.get('resource.resource')
- uom_obj = self.pool.get('product.uom')
- if context is None:
- context = {}
- res = super(project_phase, self).write(cr, uid, ids, vals, context=context)
- if context.get('scheduler',False):
- return res
- # Consider calendar and efficiency if the phase is performed by a resource
- # otherwise consider the project's working calendar
-
- #TOCHECK : why need this ?
- if isinstance(ids, (int, long)):
- ids = [ids]
- default_uom_id = self._get_default_uom_id(cr, uid)
- for phase in self.browse(cr, uid, ids, context=context):
- calendar_id = phase.project_id.resource_calendar_id and phase.project_id.resource_calendar_id.id or False
- resource_id = resource_obj.search(cr, uid, [('user_id', '=', phase.responsible_id.id)],context=context)
- if resource_id:
- cal_id = resource_obj.browse(cr, uid, resource_id[0], context=context).calendar_id.id
- if cal_id:
- calendar_id = cal_id
-
- avg_hours = uom_obj._compute_qty(cr, uid, phase.product_uom.id, phase.duration, default_uom_id)
- # Change the date_start and date_end
- # for previous and next phases respectively based on valid condition
- if vals.get('date_start', False) and vals['date_start'] < phase.date_start:
- dt_start = datetime.strptime(vals['date_start'], '%Y-%m-%d')
- work_times = resource_calendar_obj.interval_get(cr, uid, calendar_id, dt_start, avg_hours or 0.0, resource_id and resource_id[0] or False)
- if work_times:
- vals['date_end'] = work_times[-1][1].strftime('%Y-%m-%d')
- for prv_phase in phase.previous_phase_ids:
- if prv_phase.id == phase.id:
- continue
- self._check_date_start(cr, uid, prv_phase, dt_start, context=context)
-
- if vals.get('date_end', False) and vals['date_end'] > phase.date_end:
- dt_end = datetime.strptime(vals['date_end'], '%Y-%m-%d')
- work_times = resource_calendar_obj.interval_min_get(cr, uid, calendar_id, dt_end, avg_hours or 0.0, resource_id and resource_id[0] or False)
- if work_times:
- vals['date_start'] = work_times[0][0].strftime('%Y-%m-%d')
- for next_phase in phase.next_phase_ids:
- if next_phase.id == phase.id:
- continue
- self._check_date_end(cr, uid, next_phase, dt_end, context=context)
-
- return res
-
def copy(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
@@ -511,6 +462,7 @@ class project_task(osv.osv):
"""
Schedule the tasks according to resource available and priority.
"""
+ resource_pool = self.pool.get('resource.resource')
if not ids:
return False
if context is None: