2009-10-13 05:58:37 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2006-12-07 13:41:40 +00:00
|
|
|
##############################################################################
|
|
|
|
#
|
2008-11-03 19:18:56 +00:00
|
|
|
# OpenERP, Open Source Management Solution
|
2009-01-04 22:12:50 +00:00
|
|
|
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
2008-11-03 19:18:56 +00:00
|
|
|
# $Id$
|
2006-12-07 13:41:40 +00:00
|
|
|
#
|
2008-11-03 19:18:56 +00:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
2006-12-07 13:41:40 +00:00
|
|
|
#
|
2008-11-03 19:18:56 +00:00
|
|
|
# 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 General Public License for more details.
|
2006-12-07 13:41:40 +00:00
|
|
|
#
|
2008-11-03 19:18:56 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-12-07 13:41:40 +00:00
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
from osv import fields,osv
|
|
|
|
|
|
|
|
class report_project_task_user(osv.osv):
|
|
|
|
_name = "report.project.task.user"
|
|
|
|
_description = "Tasks by user and project"
|
|
|
|
_auto = False
|
|
|
|
_columns = {
|
|
|
|
'name': fields.date('Month', readonly=True),
|
2007-05-24 05:26:36 +00:00
|
|
|
'user_id':fields.many2one('res.users', 'User', readonly=True),
|
|
|
|
'project_id':fields.many2one('project.project', 'Project', readonly=True),
|
2006-12-07 13:41:40 +00:00
|
|
|
'hours_planned': fields.float('Planned Hours', readonly=True),
|
|
|
|
'hours_effective': fields.float('Effective Hours', readonly=True),
|
|
|
|
'hours_delay': fields.float('Avg. Plan.-Eff.', readonly=True),
|
|
|
|
'closing_days': fields.char('Avg Closing Delay', size=64, readonly=True),
|
|
|
|
'task_closed': fields.integer('Task Closed', readonly=True),
|
|
|
|
}
|
|
|
|
_order = 'name desc, project_id'
|
|
|
|
def init(self, cr):
|
|
|
|
cr.execute("""
|
|
|
|
create or replace view report_project_task_user as (
|
|
|
|
select
|
|
|
|
min(t.id) as id,
|
2008-01-10 09:23:07 +00:00
|
|
|
to_char(date_close, 'YYYY-MM-01') as name,
|
2006-12-07 13:41:40 +00:00
|
|
|
count(distinct t.id) as task_closed,
|
|
|
|
t.user_id,
|
|
|
|
t.project_id,
|
|
|
|
sum(planned_hours) as hours_planned,
|
2009-09-30 07:27:07 +00:00
|
|
|
to_char(avg(date_close::abstime-t.create_date::timestamp), 'DD"d" HH24:MI:SS') as closing_days,
|
2006-12-07 13:41:40 +00:00
|
|
|
sum(w.hours) as hours_effective,
|
|
|
|
((sum(planned_hours)-sum(w.hours))/count(distinct t.id))::decimal(16,2) as hours_delay
|
|
|
|
from project_task t
|
|
|
|
left join project_task_work w on (t.id=w.task_id)
|
|
|
|
where
|
|
|
|
t.state='done'
|
|
|
|
group by
|
2008-01-10 09:23:07 +00:00
|
|
|
to_char(date_close, 'YYYY-MM-01'),t.user_id,project_id
|
2006-12-07 13:41:40 +00:00
|
|
|
)
|
|
|
|
""")
|
|
|
|
report_project_task_user()
|
|
|
|
|
|
|
|
|
|
|
|
class report_project_task(osv.osv):
|
|
|
|
_name = "report.project.task"
|
|
|
|
_description = "Tasks by project"
|
|
|
|
_auto = False
|
|
|
|
_columns = {
|
|
|
|
'name': fields.date('Month', readonly=True),
|
2007-05-24 05:26:36 +00:00
|
|
|
'project_id':fields.many2one('project.project', 'Project', readonly=True),
|
2006-12-07 13:41:40 +00:00
|
|
|
'hours_planned': fields.float('Planned Hours', readonly=True),
|
|
|
|
'hours_effective': fields.float('Effective Hours', readonly=True),
|
|
|
|
'hours_delay': fields.float('Avg. Plan.-Eff.', readonly=True),
|
|
|
|
'closing_days': fields.char('Avg Closing Delay', size=64, readonly=True),
|
|
|
|
'task_closed': fields.integer('Task Closed', readonly=True),
|
|
|
|
}
|
|
|
|
_order = 'name desc, project_id'
|
|
|
|
def init(self, cr):
|
|
|
|
cr.execute("""
|
|
|
|
create or replace view report_project_task as (
|
|
|
|
select
|
|
|
|
min(t.id) as id,
|
2008-01-10 09:23:07 +00:00
|
|
|
to_char(date_close, 'YYYY-MM-01') as name,
|
2006-12-07 13:41:40 +00:00
|
|
|
count(distinct t.id) as task_closed,
|
|
|
|
t.project_id,
|
|
|
|
sum(planned_hours) as hours_planned,
|
|
|
|
to_char(avg(date_close::abstime-t.create_date::timestamp), 'DD"d" HH12:MI:SS') as closing_days,
|
|
|
|
sum(w.hours) as hours_effective,
|
|
|
|
((sum(planned_hours)-sum(w.hours))/count(distinct t.id))::decimal(16,2) as hours_delay
|
|
|
|
from project_task t
|
|
|
|
left join project_task_work w on (t.id=w.task_id)
|
|
|
|
where
|
|
|
|
t.state='done'
|
|
|
|
group by
|
2008-01-10 09:23:07 +00:00
|
|
|
to_char(date_close, 'YYYY-MM-01'),project_id
|
2006-12-07 13:41:40 +00:00
|
|
|
)
|
|
|
|
""")
|
|
|
|
report_project_task()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-07-23 14:41:47 +00:00
|
|
|
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
|
|
|