1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2008 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 ##############################################################################
23 from osv import fields,osv
25 class report_project_task_user(osv.osv):
26 _name = "report.project.task.user"
27 _description = "Tasks by user and project"
30 'name': fields.date('Month', readonly=True),
31 'user_id':fields.many2one('res.users', 'User', readonly=True),
32 'project_id':fields.many2one('project.project', 'Project', readonly=True),
33 'hours_planned': fields.float('Planned Hours', readonly=True),
34 'hours_effective': fields.float('Effective Hours', readonly=True),
35 'hours_delay': fields.float('Avg. Plan.-Eff.', readonly=True),
36 'closing_days': fields.char('Avg Closing Delay', size=64, readonly=True),
37 'task_closed': fields.integer('Task Closed', readonly=True),
39 _order = 'name desc, project_id'
42 create or replace view report_project_task_user as (
45 to_char(date_close, 'YYYY-MM-01') as name,
46 count(distinct t.id) as task_closed,
49 sum(planned_hours) as hours_planned,
50 to_char(avg(date_close::abstime-t.create_date::timestamp), 'DD"d" HH12:MI:SS') as closing_days,
51 sum(w.hours) as hours_effective,
52 ((sum(planned_hours)-sum(w.hours))/count(distinct t.id))::decimal(16,2) as hours_delay
54 left join project_task_work w on (t.id=w.task_id)
58 to_char(date_close, 'YYYY-MM-01'),t.user_id,project_id
61 report_project_task_user()
64 class report_project_task(osv.osv):
65 _name = "report.project.task"
66 _description = "Tasks by project"
69 'name': fields.date('Month', readonly=True),
70 'project_id':fields.many2one('project.project', 'Project', readonly=True),
71 'hours_planned': fields.float('Planned Hours', readonly=True),
72 'hours_effective': fields.float('Effective Hours', readonly=True),
73 'hours_delay': fields.float('Avg. Plan.-Eff.', readonly=True),
74 'closing_days': fields.char('Avg Closing Delay', size=64, readonly=True),
75 'task_closed': fields.integer('Task Closed', readonly=True),
77 _order = 'name desc, project_id'
80 create or replace view report_project_task as (
83 to_char(date_close, 'YYYY-MM-01') as name,
84 count(distinct t.id) as task_closed,
86 sum(planned_hours) as hours_planned,
87 to_char(avg(date_close::abstime-t.create_date::timestamp), 'DD"d" HH12:MI:SS') as closing_days,
88 sum(w.hours) as hours_effective,
89 ((sum(planned_hours)-sum(w.hours))/count(distinct t.id))::decimal(16,2) as hours_delay
91 left join project_task_work w on (t.id=w.task_id)
95 to_char(date_close, 'YYYY-MM-01'),project_id
104 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: