From c1132f4647f871c75eb132650d3f0610823d898b Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Fri, 5 Mar 2010 21:49:57 +0100 Subject: [PATCH] [IMP] Removed Gantt Reports on projects bzr revid: fp@tinyerp.com-20100305204957-mw3q524vvhatbycu --- addons/project/project_report.xml | 2 - addons/project/report/__init__.py | 1 - addons/project/report/_date_compute.py | 96 ----------- addons/project/report/gantt.py | 108 ------------- addons/project/report/gantt_report.py | 87 ---------- addons/project/report/project_report.xsl | 196 +++++++++++------------ 6 files changed, 98 insertions(+), 392 deletions(-) delete mode 100644 addons/project/report/_date_compute.py delete mode 100644 addons/project/report/gantt.py delete mode 100644 addons/project/report/gantt_report.py diff --git a/addons/project/project_report.xml b/addons/project/project_report.xml index db2655d021c..30816750035 100644 --- a/addons/project/project_report.xml +++ b/addons/project/project_report.xml @@ -2,7 +2,5 @@ - - diff --git a/addons/project/report/__init__.py b/addons/project/report/__init__.py index 214059ca619..2aefd8b3c11 100644 --- a/addons/project/report/__init__.py +++ b/addons/project/report/__init__.py @@ -18,7 +18,6 @@ # along with this program. If not, see . # ############################################################################## -import gantt_report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/project/report/_date_compute.py b/addons/project/report/_date_compute.py deleted file mode 100644 index ec2359403b4..00000000000 --- a/addons/project/report/_date_compute.py +++ /dev/null @@ -1,96 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from mx import DateTime - -import time -import pooler - -# -# TODO: improve sequences code -# -def _compute_tasks(cr, uid, task_list, date_begin): - sequences = [] - users = {} - tasks = {} - last_date = date_begin - for task in task_list: - # TODO: reorder ! with dependencies - if not task.planned_hours: - continue - if task.state in ('draft','open','progress') and task.user_id: - - # Find the starting date of the task - if task.user_id.id in users: - date_start = users[task.user_id.id] - else: - date_start = date_begin - sequences.sort() - for (seq,dt) in sequences: - if seqlast_date: - last_date=date_close - return tasks, last_date - -def _compute_project(cr, uid, project, date_begin): - tasks, last_date = _compute_tasks(cr, uid, project.tasks, date_begin) - for proj in project.child_ids: - d0 = DateTime.strptime(proj.date_start,'%Y-%m-%d') - if d0 > last_date: - last_date = d0 - t2, l2 = _compute_project(cr, uid, proj, last_date) - tasks.update(t2) - last_date = l2 - return tasks, last_date - -def _project_compute(cr, uid, project_id): - project = pooler.get_pool(cr.dbname).get('project.project').browse(cr, uid, project_id) - if project.date_start: - date_begin = DateTime.strptime(project.date_start, '%Y-%m-%d') - else: - date_begin = DateTime.now() - tasks, last_date = _compute_project(cr, uid, project, date_begin) - return tasks, last_date - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/project/report/gantt.py b/addons/project/report/gantt.py deleted file mode 100644 index ad69233240d..00000000000 --- a/addons/project/report/gantt.py +++ /dev/null @@ -1,108 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## -from mx.DateTime import RelativeDateTime, now, DateTime, localtime -from pychart import * -import pychart.legend -from report.misc import choice_colors - -# -# Draw a graph -# -class GanttCanvas(object): - def __init__(self, io, convertors=(lambda x:x,lambda x:x)): - self._datas = {} - self._canvas = canvas.init(fname=io, format='pdf') - self._canvas.set_author("Open ERP") - self._names = {} - self._conv = convertors - self._min = 0 - self._max = 0 - - def add(self, user, name, datas): - if hasattr(user, 'replace'): - user=user.replace('/', '//') - if hasattr(name, 'replace'): - name=name.replace('/', '//') - name = name.encode('ascii', 'ignore') - if user not in self._datas: - self._datas[user] = [] - for f in datas: - x = map(self._conv[0], f) - if x[0]self._max or not self._max: - self._max = x[1] - self._datas[user].append( (name, x)) - self._names.setdefault(name, x[0]) - - def draw(self): - colors = choice_colors(len(self._datas.keys())) - user_color = {} - for user in self._datas.keys(): - user_color[user] = colors.pop() - - names = [] - for n in self._names: - names.append((self._names[n], n)) - names.sort() - names.reverse() - def _interval_get(*args): - result = [] - for i in range(20): - d = localtime(self._min + (((self._max-self._min)/20)*(i+1))) - res = DateTime(d.year, d.month, d.day).ticks() - if (not result) or result[-1]<>res: - result.append(res) - return result - - ar = area.T(y_coord = category_coord.T(names, 1), - x_grid_style=line_style.gray50_dash1, - x_grid_interval=_interval_get, - x_range = (self._min,self._max), - x_axis=axis.X(label="Date", format=self._conv[1]), - y_axis=axis.Y(label="Tasks"), - legend = legend.T(), size = (680,450)) - - for user in self._datas: - chart_object.set_defaults(interval_bar_plot.T, direction="horizontal", data=self._datas[user]) - f = fill_style.Plain() - f.bgcolor = user_color[user] - ar.add_plot(interval_bar_plot.T(fill_styles = [f, None], label=user, cluster=(0,1))) - - ar.draw(self._canvas) - - def close(self): - self._canvas.close() - -if __name__ == '__main__': - date_to_int = lambda x: int(x.ticks()) - int_to_date = lambda x: '/a60{}'+localtime(x).strftime('%d %m %Y') - gt = GanttCanvas('test.pdf', convertors=(date_to_int, int_to_date)) - gt.add('nicoe', 'Graphe de gantt', [(DateTime(2005,6,12), DateTime(2005,6,13))]) - gt.add('nicoe', 'Tarifs', [(DateTime(2005,6,19), DateTime(2005,6,21))]) - gt.add('gaetan', 'Calcul des prix', [(DateTime(2005,6,12), DateTime(2005,6,13))]) - gt.add('nico', 'Mise a jour du site', [(DateTime(2005,6,13), DateTime(2005,6,16))]) - gt.add('tom', 'Coucou', [(DateTime(2005,6,11), DateTime(2005,6,12))]) - gt.draw() - gt.close() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/project/report/gantt_report.py b/addons/project/report/gantt_report.py deleted file mode 100644 index b07f40c1a33..00000000000 --- a/addons/project/report/gantt_report.py +++ /dev/null @@ -1,87 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from mx.DateTime import * - -import StringIO - -from report.render import render -from report.interface import report_int - -from gantt import GanttCanvas -from _date_compute import _project_compute, _compute_tasks -import pooler - -class external_pdf(render): - def __init__(self, pdf): - render.__init__(self) - self.pdf = pdf - self.output_type='pdf' - - def _render(self): - return self.pdf - -class report_tasks(report_int): - def create(self, cr, uid, ids, datas, context={}): - io = StringIO.StringIO() - - date_to_int = lambda x: int(x.ticks()) - int_to_date = lambda x: '/a60{}'+localtime(x).strftime('%d %m %Y') - gt = GanttCanvas(io, convertors=(date_to_int, int_to_date)) - - tasks = pooler.get_pool(cr.dbname).get('project.task').browse(cr, uid, ids) - tasks, last_date = _compute_tasks(cr, uid, tasks, now()) - for user_id in tasks.keys(): - for t in tasks[user_id]: - gt.add(t[3], t[2], [(t[0],t[1])]) - try: - gt.draw() - except: - pass - gt.close() - self.obj = external_pdf(io.getvalue()) - self.obj.render() - return (self.obj.pdf, 'pdf') -report_tasks('report.project.tasks.gantt') - - -class report_projects(report_int): - def create(self, cr, uid, ids, datas, context={}): - io = StringIO.StringIO() - date_to_int = lambda x: int(x.ticks()) - int_to_date = lambda x: '/a60{}'+localtime(x).strftime('%d %m %Y') - gt = GanttCanvas(io, convertors=(date_to_int, int_to_date)) - tasks, last_date = _project_compute(cr, uid, ids[0]) - for user_id in tasks.keys(): - for t in tasks[user_id]: - gt.add(t[3], t[2], [(t[0],t[1])]) - try: - gt.draw() - except: - pass - gt.close() - self.obj = external_pdf(io.getvalue()) - self.obj.render() - return (self.obj.pdf, 'pdf') -report_projects('report.project.project.gantt') - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/project/report/project_report.xsl b/addons/project/report/project_report.xsl index ece65ee7503..4da259ccf06 100644 --- a/addons/project/report/project_report.xsl +++ b/addons/project/report/project_report.xsl @@ -1,108 +1,108 @@ - - - + + + - - - + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - (), - + + (), + - - - - - - - - - - - - + + + + + + + + + + + + - - - - Tasks - Hours - Done - Deadline - Responsible - - - - + + + + Tasks + Hours + Done + Deadline + Responsible + + + + - - - - - - - - Manager: - - Members: - - - Project: - - - - - Date Start: - - Date Stop: - - - Planned Hours: - - Effective Hours: - - - - -
-			
-		
- - - -
+ + + + + + + + Manager: + + Members: + + + Project: + + + + + Date Start: + + Date Stop: + + + Planned Hours: + + Effective Hours: + + + + +
+            
+        
+ + + +