From b94cba849fdd9cf696711c2349b2a3723b4f7bc9 Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Thu, 18 Mar 2010 16:30:50 +0530 Subject: [PATCH] [IMP]:hr_holidays:Improved Available holidays report. bzr revid: apa@tinyerp.com-20100318110050-lmkbwstxy99tx383 --- .../hr_holidays/report/available_holidays.py | 37 +++++++++++--- .../report/available_holidays_view.xml | 50 ++++++++++++++++++- 2 files changed, 79 insertions(+), 8 deletions(-) diff --git a/addons/hr_holidays/report/available_holidays.py b/addons/hr_holidays/report/available_holidays.py index 2b9441ccddb..4a1972f1f7d 100644 --- a/addons/hr_holidays/report/available_holidays.py +++ b/addons/hr_holidays/report/available_holidays.py @@ -25,11 +25,17 @@ class available_holidays_report(osv.osv): _name = "available.holidays.report" _auto = False _columns = { + 'date': fields.datetime('Date', readonly=True), + 'year': fields.char('Year', size=4, readonly=True), + 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), + ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), + ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), 'employee_id': fields.many2one ('hr.employee', 'Employee', readonly=True), 'holiday_status_id': fields.many2one('hr.holidays.status', 'Leave Type', readonly=True), - # 'max_leave': fields.float('Allocated Leaves', readonly=True), -# 'taken_leaves': fields.float('Taken Leaves', readonly=True), + 'max_leave': fields.float('Allocated Leaves', readonly=True), + 'taken_leaves': fields.float('Taken Leaves', readonly=True), 'remaining_leave': fields.float('Remaining Leaves',readonly=True), + 'user_id':fields.many2one('res.users', 'User', readonly=True), } def init(self, cr): tools.drop_view_if_exists(cr, 'available_holidays_report') @@ -37,16 +43,33 @@ class available_holidays_report(osv.osv): create or replace view available_holidays_report as ( select min(h.id) as id, + date_trunc('day',h.create_date) as date, + to_char(s.create_date, 'YYYY') as year, + to_char(s.create_date, 'MM') as month, h.employee_id as employee_id, + h.user_id as user_id, + h.state as state, h.holiday_status_id as holiday_status_id, - sum(number_of_days) as remaining_leave - from - hr_holidays h + sum(number_of_days) as remaining_leave, + (select sum(number_of_days_temp) from hr_holidays + where type='remove' + and employee_id=h.employee_id + and holiday_status_id=h.holiday_status_id + and state='validate') as taken_leaves, + (select sum(number_of_days_temp) from hr_holidays + where type='add' + and employee_id=h.employee_id + and holiday_status_id=h.holiday_status_id + and state='validate') as max_leave + from hr_holidays h left join hr_holidays_status s on (s.id = h.holiday_status_id) - where h.state = 'validate' + where h.state='validate' and h.employee_id is not null and s.active <> 'f' - group by h.holiday_status_id, h.employee_id + group by h.holiday_status_id, h.employee_id, + date_trunc('day',h.create_date),to_char(s.create_date, 'YYYY'), + to_char(s.create_date, 'MM'),h.user_id,h.state + )""") available_holidays_report() diff --git a/addons/hr_holidays/report/available_holidays_view.xml b/addons/hr_holidays/report/available_holidays_view.xml index bfd009361ee..4587cc1f84a 100644 --- a/addons/hr_holidays/report/available_holidays_view.xml +++ b/addons/hr_holidays/report/available_holidays_view.xml @@ -12,7 +12,13 @@ + + + + + + @@ -42,6 +48,48 @@ + + available.holidays.report.search + available.holidays.report + search + + + + + + + + + + + + + + + + + + + + + + @@ -49,7 +97,7 @@ available.holidays.report form tree,graph - +