diff options
| author | husen daudi <hda@hda> | 2009-04-13 18:13:13 +0530 |
|---|---|---|
| committer | husen daudi <hda@hda> | 2009-04-13 18:13:13 +0530 |
| commit | ea2efc15067b3b5f6448a5bce7baae8880c7bfbb (patch) | |
| tree | 921b362d733c0e601792aa59955a81cd70722f3a /addons/report_task/report_task.py | |
| parent | 7767525f1edc8c5e7dd32678ffce9ed2d19310a7 (diff) | |
| parent | 4b180641bdc3356ec778a98bc10d936042a8fc12 (diff) | |
Ported all bugs from trunk to stable
bzr revid: hda@hda-20090413124313-x9gdobzpxf1lkfxl
Diffstat (limited to 'addons/report_task/report_task.py')
| -rw-r--r-- | addons/report_task/report_task.py | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/addons/report_task/report_task.py b/addons/report_task/report_task.py index 92272468c9b..5fa73654094 100644 --- a/addons/report_task/report_task.py +++ b/addons/report_task/report_task.py @@ -21,6 +21,7 @@ ############################################################################## from osv import fields,osv +import mx.DateTime class report_task_user_pipeline_open (osv.osv): _name = "report.task.user.pipeline.open" @@ -58,7 +59,100 @@ class report_task_user_pipeline_open (osv.osv): ''') report_task_user_pipeline_open() +class report_closed_task(osv.osv): + _name = "report.closed.task" + _description = "Closed Task Report" + _auto = False + _columns = { + 'sequence': fields.integer('Sequence', readonly=True), + 'name': fields.char('Task summary', size=128, readonly=True), + 'project_id': fields.many2one('project.project', 'Project', readonly=True), + 'user_id': fields.many2one('res.users', 'Assigned to', readonly=True), + 'date_deadline': fields.datetime('Deadline', readonly=True), + 'planned_hours': fields.float('Planned Hours', readonly=True), + 'delay_hours': fields.float('Delay Hours', readonly=True), + 'progress': fields.float('Progress (%)', readonly=True), + 'priority' : fields.selection([('4','Very Low'), ('3','Low'), ('2','Medium'), ('1','Urgent'), ('0','Very urgent')], 'Importance', readonly=True), + 'state': fields.selection([('draft', 'Draft'),('open', 'In Progress'),('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')], 'Status', readonly=True), + 'remaining_hours': fields.float('Remaining Hours', readonly=True), + 'date_close' : fields.datetime('Date Closed', readonly=True) + } + + def init(self, cr): + cr.execute(''' + create or replace view report_closed_task as ( + select + tsk.id as id, tsk.sequence as sequence, tsk.name as name, + tsk.project_id as project_id, tsk.user_id as user_id, + tsk.date_deadline as date_deadline, tsk.planned_hours as planned_hours, + tsk.delay_hours as delay_hours, tsk.progress as progress, + tsk.priority as priority, tsk.state as state, + tsk.remaining_hours as remaining_hours, tsk.date_close as date_close + from + project_task tsk + where + (tsk.date_close <= CURRENT_DATE AND tsk.date_close > (CURRENT_DATE-15)) + ) + ''') +report_closed_task() + +class report_timesheet_task_user(osv.osv): + _name = "report.timesheet.task.user" + _auto = False + _order = "name" + + def _get_task_hours(self, cr, uid, ids, name,args,context): + result = {} + for record in self.browse(cr, uid, ids,context): + last_date = mx.DateTime.strptime(record.name, '%Y-%m-%d') + mx.DateTime.RelativeDateTime(months=1) - 1 + task_obj=self.pool.get('project.task.work') + task_ids = task_obj.search(cr,uid,[('user_id','=',record.user_id.id),('date','>=',record.name),('date','<=',last_date.strftime('%Y-%m-%d'))]) + tsk_hrs = task_obj.read(cr,uid,task_ids,['hours','date','user_id']) + total = 0.0 + for hrs in tsk_hrs: + total += hrs['hours'] + result[record.id] = total + return result + + def get_hrs_timesheet(self, cr, uid, ids, name,args,context): + result = {} + sum = 0.0 + for record in self.browse(cr, uid, ids, context): + last_date = mx.DateTime.strptime(record.name, '%Y-%m-%d') + mx.DateTime.RelativeDateTime(months=1) - 1 + obj=self.pool.get('hr_timesheet_sheet.sheet.day') + sheet_ids = obj.search(cr,uid,[('sheet_id.user_id','=',record.user_id.id),('name','>=',record.name),('name','<=',last_date.strftime('%Y-%m-%d'))]) + data_days = obj.read(cr,uid,sheet_ids,['name','sheet_id.user_id','total_attendance']) + total = 0.0 + for day_attendance in data_days: + total += day_attendance['total_attendance'] + result[record.id] = total + return result + + _columns = { + 'name': fields.date('Month',readonly=True), + 'user_id': fields.many2one('res.users', 'User',readonly=True), + 'timesheet_hrs': fields.function(get_hrs_timesheet, method=True, string="Timesheet Hours"), + 'task_hrs': fields.function(_get_task_hours, method=True, string="Task Hours"), + } + + + def init(self, cr): + cr.execute(""" create or replace view report_timesheet_task_user as ( + select + ((r.id*12)+to_number(months.m_id,'99'))::integer as id, + months.name as name, + r.id as user_id + from res_users r, + (select to_char(p.date,'YYYY-MM-01') as name, + to_char(p.date,'MM') as m_id + from project_task_work p + + union + select to_char(h.name,'YYYY-MM-01') as name, + to_char(h.name,'MM') as m_id + from hr_timesheet_sheet_sheet_day h) as months) """) +report_timesheet_task_user() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
