1 ##############################################################################
3 # Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
5 # $Id: project.py 1005 2005-07-25 08:41:42Z nicoe $
7 # WARNING: This program as such is intended to be used by professional
8 # programmers who take the whole responsability of assessing all potential
9 # consequences resulting from its eventual inadequacies and bugs
10 # End users who are looking for a ready-to-use solution with commercial
11 # garantees and support are strongly adviced to contract a Free Software
14 # This program is Free Software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License
16 # as published by the Free Software Foundation; either version 2
17 # of the License, or (at your option) any later version.
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 ##############################################################################
30 from osv import fields,osv
32 class report_project_task_user(osv.osv):
33 _name = "report.project.task.user"
34 _description = "Tasks by user and project"
37 'name': fields.date('Month', readonly=True),
38 'user_id':fields.many2one('res.users', 'User', readonly=True, relate=True),
39 'project_id':fields.many2one('project.project', 'Project', readonly=True, relate=True),
40 'hours_planned': fields.float('Planned Hours', readonly=True),
41 'hours_effective': fields.float('Effective Hours', readonly=True),
42 'hours_delay': fields.float('Avg. Plan.-Eff.', readonly=True),
43 'closing_days': fields.char('Avg Closing Delay', size=64, readonly=True),
44 'task_closed': fields.integer('Task Closed', readonly=True),
46 _order = 'name desc, project_id'
49 create or replace view report_project_task_user as (
52 substring(date_close for 7)||'-01' as name,
53 count(distinct t.id) as task_closed,
56 sum(planned_hours) as hours_planned,
57 to_char(avg(date_close::abstime-t.create_date::timestamp), 'DD"d" HH12:MI:SS') as closing_days,
58 sum(w.hours) as hours_effective,
59 ((sum(planned_hours)-sum(w.hours))/count(distinct t.id))::decimal(16,2) as hours_delay
61 left join project_task_work w on (t.id=w.task_id)
65 substring(date_close for 7),t.user_id,project_id
68 report_project_task_user()
71 class report_project_task(osv.osv):
72 _name = "report.project.task"
73 _description = "Tasks by project"
76 'name': fields.date('Month', readonly=True),
77 'project_id':fields.many2one('project.project', 'Project', readonly=True, relate=True),
78 'hours_planned': fields.float('Planned Hours', readonly=True),
79 'hours_effective': fields.float('Effective Hours', readonly=True),
80 'hours_delay': fields.float('Avg. Plan.-Eff.', readonly=True),
81 'closing_days': fields.char('Avg Closing Delay', size=64, readonly=True),
82 'task_closed': fields.integer('Task Closed', readonly=True),
84 _order = 'name desc, project_id'
87 create or replace view report_project_task as (
90 substring(date_close for 7)||'-01' as name,
91 count(distinct t.id) as task_closed,
93 sum(planned_hours) as hours_planned,
94 to_char(avg(date_close::abstime-t.create_date::timestamp), 'DD"d" HH12:MI:SS') as closing_days,
95 sum(w.hours) as hours_effective,
96 ((sum(planned_hours)-sum(w.hours))/count(distinct t.id))::decimal(16,2) as hours_delay
98 left join project_task_work w on (t.id=w.task_id)
102 substring(date_close for 7),project_id
105 report_project_task()