From bb50f760f7357ae2ca1546969ebd30ac0c09a0e0 Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Tue, 27 Apr 2010 15:13:43 +0530 Subject: [PATCH] [IMP]:hr_holidays:Improved SQL report.(Leaves). bzr revid: apa@tinyerp.com-20100427094343-mbfa6xv6mgri5xqj --- .../hr_holidays/report/hr_holidays_report.py | 17 ++- .../report/hr_holidays_report_view.xml | 109 +++++++++++------- 2 files changed, 81 insertions(+), 45 deletions(-) diff --git a/addons/hr_holidays/report/hr_holidays_report.py b/addons/hr_holidays/report/hr_holidays_report.py index 435eee71ea5..c060521af0d 100644 --- a/addons/hr_holidays/report/hr_holidays_report.py +++ b/addons/hr_holidays/report/hr_holidays_report.py @@ -30,14 +30,17 @@ class hr_holidays_report(osv.osv): _columns = { 'date': fields.datetime('Date', readonly=True), 'year': fields.char('Year', size=4, readonly=True), + 'day': fields.char('Day', size=15, 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), 'date_from' : fields.datetime('Start Date', readonly=True), 'date_to' : fields.datetime('End Date', readonly=True), - 'number_of_days_temp': fields.float('Number of Days', readonly=True), + 'number_of_days_temp': fields.float('#Days', readonly=True), 'employee_id' : fields.many2one('hr.employee', "Employee's Name",readonly=True), 'user_id':fields.many2one('res.users', 'User', readonly=True), + 'holiday_status_id' : fields.many2one("hr.holidays.status", "Leave Type",readonly=True), + 'department_id':fields.many2one('hr.department','Department',readonly=True), 'state': fields.selection([('draft', 'Draft'), ('confirm', 'Waiting Validation'), ('refuse', 'Refused'), @@ -52,21 +55,25 @@ class hr_holidays_report(osv.osv): create or replace view hr_holidays_report as ( select min(s.id) as id, - date_trunc('seconds',s.create_date) as date, + date_trunc('day',s.create_date) as date, date_trunc('day',s.date_from) as date_from, date_trunc('day',s.date_to) as date_to, - s.number_of_days_temp, + sum(s.number_of_days_temp) as number_of_days_temp, s.employee_id, s.user_id as user_id, to_char(s.create_date, 'YYYY') as year, to_char(s.create_date, 'MM') as month, + to_char(s.create_date, 'YYYY-MM-DD') as day, + s.holiday_status_id, + s.department_id, s.state from hr_holidays s where type='remove' group by s.create_date,s.state,s.date_from,s.date_to, - s.number_of_days_temp,s.employee_id,s.user_id + s.employee_id,s.user_id,s.holiday_status_id, + s.department_id ) """) hr_holidays_report() @@ -98,7 +105,7 @@ class hr_holidays_remaining_leaves_user(osv.osv): where hrs.employee_id = hre.id and hre.resource_id = rr.id and - hhs.id = hrs.holiday_status_id + hhs.id = hrs.holiday_status_id group by rr.name,rr.user_id,hhs.name ) diff --git a/addons/hr_holidays/report/hr_holidays_report_view.xml b/addons/hr_holidays/report/hr_holidays_report_view.xml index e9e0e6aae36..c5f2a41afb7 100644 --- a/addons/hr_holidays/report/hr_holidays_report_view.xml +++ b/addons/hr_holidays/report/hr_holidays_report_view.xml @@ -7,14 +7,17 @@ tree - - - - - + + + + + + + + - + @@ -27,6 +30,7 @@ + @@ -37,44 +41,69 @@ search - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + - - + + + @@ -85,7 +114,7 @@ hr.holidays.report form tree,graph - {'search_default_employee': 1} + {'search_default_month':1,'search_default_Employee':1,'group_by_no_leaf':1,'group_by':[]}