[FIX] project_long_term: fix

bzr revid: hmo@tinyerp.com-20101231115754-f4gvpijitxqme15j
This commit is contained in:
Harry (OpenERP)
2010-12-31 17:27:54 +05:30
parent 2f3f2423dc
commit db3ecb0649
@@ -19,7 +19,7 @@
#
##############################################################################
from datetime import datetime
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
from tools.translate import _
from osv import fields, osv
@@ -246,8 +246,10 @@ class project_phase(osv.osv):
if not start_date:
start_date = phase.project_id.date_start or phase.date_start or datetime.now().strftime("%Y-%m-%d")
start_date = datetime.strftime((datetime.strptime(start_date, "%Y-%m-%d")), "%Y-%m-%d")
phase_resource_obj = resource_pool.generate_resources(cr, uid, [phase.responsible_id.id], calendar_id, context=context)
phase_resource_obj = self.generate_resources(cr, uid, [phase.id], context=context)[phase.id]
avg_days = uom_pool._compute_qty(cr, uid, phase.product_uom.id, phase.duration, day_uom_id)
if not phase_resource_obj: #TOCHECK: why need this ?
avg_days = avg_days - 1
duration = str(avg_days) + 'd'
# Create a new project for each phase
def Project():
@@ -295,10 +297,10 @@ class project_phase(osv.osv):
'date_end': end_date.strftime('%Y-%m-%d')
}, context=ctx)
# Recursive call till all the next phases scheduled
for phase in phase.next_phase_ids:
if phase.state in ['draft', 'open', 'pending']:
id_cal = phase.project_id.resource_calendar_id and phase.project_id.resource_calendar_id.id or False
self.generate_schedule(cr, uid, [phase.id], date_start, id_cal, context=context)
for next_phase in phase.next_phase_ids:
if next_phase.state in ['draft', 'open', 'pending']:
id_cal = next_phase.project_id.resource_calendar_id and next_phase.project_id.resource_calendar_id.id or False
self.generate_schedule(cr, uid, [next_phase.id], date_start+timedelta(days=1), id_cal, context=context)
else:
continue
return True