summaryrefslogtreecommitdiff
path: root/addons/project_long_term/project_long_term.py
diff options
context:
space:
mode:
authorUjjvala Collins (OpenERP) <uco@tinyerp.com>2011-09-16 10:48:03 +0530
committerUjjvala Collins (OpenERP) <uco@tinyerp.com>2011-09-16 10:48:03 +0530
commitde4a858a258fa20b4e1decf23bce1c1e409a17ef (patch)
tree63f3c1bb443695781ac1684bbd1b46c76efb6bb7 /addons/project_long_term/project_long_term.py
parent726b1b96efefa1c6b57521ceec74eae021e0b7aa (diff)
parentd101d3fbaaffe2d0219ac6cfeef50338a2501664 (diff)
[MERGE]: Merged with trunk-addons.
bzr revid: uco@tinyerp.com-20110916051803-2c4c7i7j2s7bkrr8
Diffstat (limited to 'addons/project_long_term/project_long_term.py')
-rw-r--r--addons/project_long_term/project_long_term.py33
1 files changed, 23 insertions, 10 deletions
diff --git a/addons/project_long_term/project_long_term.py b/addons/project_long_term/project_long_term.py
index c2bc55db212..6c5ef7890bf 100644
--- a/addons/project_long_term/project_long_term.py
+++ b/addons/project_long_term/project_long_term.py
@@ -23,6 +23,7 @@ from datetime import datetime
from tools.translate import _
from osv import fields, osv
from resource.faces import task as Task
+from operator import itemgetter
class project_phase(osv.osv):
_name = "project.phase"
@@ -119,7 +120,7 @@ class project_phase(osv.osv):
'state': fields.selection([('draft', 'Draft'), ('open', 'In Progress'), ('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')], 'State', readonly=True, required=True,
help='If the phase is created the state \'Draft\'.\n If the phase is started, the state becomes \'In Progress\'.\n If review is needed the phase is in \'Pending\' state.\
\n If the phase is over, the states is set to \'Done\'.'),
- 'total_hours': fields.function(_compute, method=True, string='Total Hours'),
+ 'total_hours': fields.function(_compute, string='Total Hours'),
}
_defaults = {
'responsible_id': lambda obj,cr,uid,context: uid,
@@ -379,8 +380,8 @@ def Phase_%d():
end_date = task.end.to_datetime()
task_pool.write(cr, uid, [task_id], {
- 'date_start': start_date.strftime('%Y-%m-%d'),
- 'date_end': end_date.strftime('%Y-%m-%d')
+ 'date_start': start_date.strftime('%Y-%m-%d %H:%M:%S'),
+ 'date_end': end_date.strftime('%Y-%m-%d %H:%M:%S')
}, context=context)
return True
project_phase()
@@ -398,7 +399,7 @@ class project_resource_allocation(osv.osv):
res[allocation.id] = name
return res
_columns = {
- 'name': fields.function(get_name, method=True, type='char', size=256),
+ 'name': fields.function(get_name, type='char', size=256),
'resource_id': fields.many2one('resource.resource', 'Resource', required=True),
'phase_id': fields.many2one('project.phase', 'Project Phase', ondelete='cascade', required=True),
'project_id': fields.related('phase_id', 'project_id', type='many2one', relation="project.project", string='Project', store=True),
@@ -570,8 +571,8 @@ def Project_%d():
phase_pool.write(cr, uid, [phase_id], {
- 'date_start': start_date.strftime('%Y-%m-%d'),
- 'date_end': end_date.strftime('%Y-%m-%d')
+ 'date_start': start_date.strftime('%Y-%m-%d'),
+ 'date_end': end_date.strftime('%Y-%m-%d')
}, context=context)
return True
@@ -695,8 +696,8 @@ def Project_%d():
end_date = task.end.to_datetime()
task_pool.write(cr, uid, [task_id], {
- 'date_start': start_date.strftime('%Y-%m-%d'),
- 'date_end': end_date.strftime('%Y-%m-%d')
+ 'date_start': start_date.strftime('%Y-%m-%d %H:%M:%S'),
+ 'date_end': end_date.strftime('%Y-%m-%d %H:%M:%S')
}, context=context)
return True
@@ -729,8 +730,9 @@ class project_task(osv.osv):
if context is None:
context = {}
task = self.browse(cr, uid, task_id, context=context)
- duration = str(task.planned_hours )+ 'H'
+ duration = str(task.planned_hours)+ 'H'
str_resource = False
+ parent = task.parent_ids
if task.phase_id.resource_ids:
str_resource = ('%s | '*len(task.phase_id.resource_ids))[:-2]
str_resource = str_resource % tuple(map(lambda x: 'Resource_%s'%x.resource_id.id, task.phase_id.resource_ids))
@@ -742,7 +744,12 @@ class project_task(osv.osv):
effort = \'%s\'
resource = %s
'''%(task.id, task.name, duration, str_resource)
- #start = datetime.strftime((datetime.strptime(start, "%Y-%m-%d")), "%Y-%m-%d")
+ if task.child_ids:
+ seq = [[child.planned_hours, child.id] for child in task.child_ids]
+ seq.sort(key=itemgetter(0))
+ s +='''
+ start = up.Task_%s.end
+ '''%(seq[-1][1])
else:
s = '''
def Task_%s():
@@ -750,6 +757,12 @@ class project_task(osv.osv):
effort = \'%s\'
resource = %s
'''%(task.id, task.name, duration, str_resource)
+ if task.child_ids:
+ seq = [[child.planned_hours, child.id] for child in task.child_ids]
+ seq.sort(key=itemgetter(0))
+ s +='''
+ start = up.Task_%s.end
+'''%(seq[-1][1])
s += '\n'
return s
project_task()