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 ##############################################################################
23 from osv import fields,osv
25 class report_task_user_pipeline_open (osv.osv):
26 _name = "report.task.user.pipeline.open"
27 _description = "Tasks by user and project"
30 'user_id':fields.many2one('res.users', 'User', readonly=True),
31 'task_nbr': fields.float('Task Number', readonly=True),
32 'task_hrs': fields.float('Task Hours', readonly=True),
33 'task_progress': fields.float('Task Progress', readonly=True),
34 'company_id' : fields.many2one('res.company', 'Company'),
35 'task_state': fields.selection([('draft', 'Draft'),('open', 'Open'),('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done'),('no','No Task')], 'Status', readonly=True),
40 create or replace view report_task_user_pipeline_open as (
44 u.company_id as company_id,
45 count(t.*) as task_nbr,
46 sum(t.planned_hours) as task_hrs,
47 sum(t.planned_hours * (100 - t.progress) / 100) as task_progress,
48 case when t.state is null then 'no' else t.state end as task_state
52 project_task t on (u.id = t.user_id)
56 u.id, u.company_id, t.state
59 report_task_user_pipeline_open()
61 class report_closed_task(osv.osv):
62 _name = "report.closed.task"
63 _description = "Closed Task Report"
66 'sequence': fields.integer('Sequence', readonly=True),
67 'name': fields.char('Task summary', size=128, readonly=True),
68 'project_id': fields.many2one('project.project', 'Project', readonly=True),
69 'user_id': fields.many2one('res.users', 'Assigned to', readonly=True),
70 'date_deadline': fields.datetime('Deadline', readonly=True),
71 'planned_hours': fields.float('Planned Hours', readonly=True),
72 'delay_hours': fields.float('Delay Hours', readonly=True),
73 'progress': fields.float('Progress (%)', readonly=True),
74 'priority' : fields.selection([('4','Very Low'), ('3','Low'), ('2','Medium'), ('1','Urgent'), ('0','Very urgent')], 'Importance', readonly=True),
75 'state': fields.selection([('draft', 'Draft'),('open', 'In Progress'),('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')], 'Status', readonly=True),
76 'remaining_hours': fields.float('Remaining Hours', readonly=True),
77 'date_close' : fields.datetime('Date Closed', readonly=True)
82 create or replace view report_closed_task as (
84 tsk.id as id, tsk.sequence as sequence, tsk.name as name,
85 tsk.project_id as project_id, tsk.user_id as user_id,
86 tsk.date_deadline as date_deadline, tsk.planned_hours as planned_hours,
87 tsk.delay_hours as delay_hours, tsk.progress as progress,
88 tsk.priority as priority, tsk.state as state,
89 tsk.remaining_hours as remaining_hours, tsk.date_close as date_close
93 (tsk.date_close < CURRENT_DATE AND tsk.date_close >= (CURRENT_DATE-15))
98 #class report_timesheet_task(osv.osv):
99 # _name = "report.timesheet.task"
100 # _description = "Report on Timesheets and Tasks per User Per Month"
103 # def get_hrs_timesheet(self, cr, uid, ids, name,args,context):
106 # for record in self.browse(cr, uid, ids, context):
107 # last_date = mx.DateTime.strptime(record.month, '%Y-%m-%d') + mx.DateTime.RelativeDateTime(months=1) - 1
108 # obj=self.pool.get('hr_timesheet_sheet.sheet')
109 # sheet_ids = obj.search(cr,uid,[('user_id','=',record.user_id.id),('date_current','>=',record.month),('date_current','<=',last_date.strftime('%Y-%m-%d'))])
110 # data_days = obj.read(cr,uid,sheet_ids,['total_attendance_day','date_current','user_id'])
112 # for day_attendance in data_days:
113 # total += day_attendance['total_attendance_day']
114 # result[record.id] = total
119 # 'month': fields.date('Month', required=True,readonly=True),
120 # 'user_id': fields.many2one('res.users', 'User' ,readonly=True, required=True),
121 # 'timesheet_hrs': fields.function(get_hrs_timesheet,method=True, string="Timesheet Hrs" ),
122 # 'task_hrs': fields.float('Task Hrs', readonly=True, required=True),
126 # def init(self, cr):
127 # cr.execute("""create or replace view report_timesheet_task as (
128 # select min(p.id) as id, to_char(p.date, 'YYYY-MM-01') as month, min(r.id) as user_id, sum(p.hours) as task_hrs,0.0 as timesheet_hrs
129 # from project_task_work p,res_users r
130 # where (r.id=p.user_id)
131 # group by to_char(p.date, 'YYYY-MM-01'))""")
135 #report_timesheet_task()
137 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: