1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
24 from mx import DateTime
27 def compute_burndown(cr, uid, tasks_id, date_start, date_stop):
30 cr.execute('select id,create_date,state,planned_hours from project_task where id in %s order by create_date', (tuple(tasks_id),))
33 cr.execute('select w.date,w.hours from project_task_work w left join project_task t on (t.id=w.task_id) where t.id in %s and t.state in (\'open\',\'progress\') order by date', (tuple(tasks_id),))
35 tasks2 = cr.fetchall()
37 cr.execute('select date_close,planned_hours from project_task where id in %s and state in (\'cancelled\',\'done\') order by date_close', (tuple(tasks_id),))
38 tasks2 += cr.fetchall()
44 current_date = date_start
48 while current_date<=date_stop:
49 while len(tasks) and tasks[0][1] and tasks[0][1][:10]<=current_date:
54 if tasks2[i][0] and tasks2[i][0][:10]<=current_date:
59 result.append( (int(time.mktime(time.strptime(current_date,'%Y-%m-%d'))), total-done) )
60 current_date = (DateTime.strptime(current_date, '%Y-%m-%d') + DateTime.RelativeDateTime(days=1)).strftime('%Y-%m-%d')
61 if not len(tasks) and not len(tasks2):
63 result.append( (int(time.mktime(time.strptime(date_stop,'%Y-%m-%d'))), 0) )
66 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: