From 65b33b9489c8561a1ea1426cace8911f5b6a05bd Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Wed, 29 Dec 2010 17:51:30 +0100 Subject: [PATCH] [FIX] Cleaning hr holidays reporting and dashbaords bzr revid: fp@tinyerp.com-20101229165130-jfr2h23jo7mrjqzu --- addons/hr_holidays/board_hr_holidays_view.xml | 52 ++------ .../board_hr_manager_holidays_view.xml | 36 ++---- addons/hr_holidays/hr_holidays.py | 2 +- .../hr_holidays/report/available_holidays.py | 68 ---------- .../report/available_holidays_view.xml | 117 ++---------------- .../hr_holidays/security/ir.model.access.csv | 2 - 6 files changed, 29 insertions(+), 248 deletions(-) diff --git a/addons/hr_holidays/board_hr_holidays_view.xml b/addons/hr_holidays/board_hr_holidays_view.xml index 5d3223545b5..71b4e2a98fb 100644 --- a/addons/hr_holidays/board_hr_holidays_view.xml +++ b/addons/hr_holidays/board_hr_holidays_view.xml @@ -10,52 +10,16 @@ parent="base.menu_hr_dasboard" sequence="4"/> - - hr.holidays.allocation.leave.tree - hr.holidays - tree - - - - - - - - - - - My Leaves - ir.actions.act_window - hr.holidays - form - tree,form - [('state','in',('confirm', 'validate')),('user_id','=',uid)] - - - - - board.hr.holidays.form - board.board - - form - - - - - - - - - Leaves by Month - ir.actions.act_window - available.holidays.report + + My Leaves + hr.holidays.status form - graph,tree - [('user_id','=',uid)] - {'group_by':['holiday_status_id'],'group_by_no_leaf':1} - + tree,form + + {} + [] board.hr.holidays.leave.month.form @@ -64,7 +28,7 @@ - + diff --git a/addons/hr_holidays/board_hr_manager_holidays_view.xml b/addons/hr_holidays/board_hr_manager_holidays_view.xml index eb3af2781f6..980a8dd5fbb 100644 --- a/addons/hr_holidays/board_hr_manager_holidays_view.xml +++ b/addons/hr_holidays/board_hr_manager_holidays_view.xml @@ -3,53 +3,33 @@ - All Employee Leaves + Leaves To Validate ir.actions.act_window hr.holidays form tree,form - [('state','in',('confirm', 'validate'))] + [('state','in',('confirm', 'validate', 'validate1'))] - - - Remaining Leaves by User - ir.actions.act_window - hr.holidays.remaining.leaves.user - form - graph,tree - - board.hr.holidays.manager.form board.board - + form - - - - - - - - board.hr.holidays.manager.remaining.form - board.board - form - - - - - + + + + + sequence="5"/> diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 76eb2a76595..83276ae63ee 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -79,7 +79,7 @@ class hr_holidays_status(osv.osv): 'color_name': fields.selection([('red', 'Red'),('blue','Blue'), ('lightgreen', 'Light Green'), ('lightblue','Light Blue'), ('lightyellow', 'Light Yellow'), ('magenta', 'Magenta'),('lightcyan', 'Light Cyan'),('black', 'Black'),('lightpink', 'Light Pink'),('brown', 'Brown'),('violet', 'Violet'),('lightcoral', 'Light Coral'),('lightsalmon', 'Light Salmon'),('lavender', 'Lavender'),('wheat', 'Wheat'),('ivory', 'Ivory')],'Color in Report', required=True, help='This color will be used in the leaves summary located in Reporting\Leaves by Departement'), 'limit': fields.boolean('Allow to Override Limit', help='If you tick this checkbox, the system will allow, for this section, the employees to take more leaves than the available ones.'), 'active': fields.boolean('Active', help="If the active field is set to false, it will allow you to hide the leave type without removing it."), - 'max_leaves': fields.function(_user_left_days, method=True, string='Maximum Leaves Allowed', help='This value is given by the sum of all holidays requests with a positive value.', multi='user_left_days'), + 'max_leaves': fields.function(_user_left_days, method=True, string='Maximum Allowed', help='This value is given by the sum of all holidays requests with a positive value.', multi='user_left_days'), 'leaves_taken': fields.function(_user_left_days, method=True, string='Leaves Already Taken', help='This value is given by the sum of all holidays requests with a negative value.', multi='user_left_days'), 'remaining_leaves': fields.function(_user_left_days, method=True, string='Remaining Leaves', help='Maximum Leaves Allowed - Leaves Already Taken', multi='user_left_days'), 'double_validation': fields.boolean('Apply Double Validation', help="If its True then its Allocation/Request have to be validated by second validator") diff --git a/addons/hr_holidays/report/available_holidays.py b/addons/hr_holidays/report/available_holidays.py index 8d91e0d02e4..26c654db9dd 100644 --- a/addons/hr_holidays/report/available_holidays.py +++ b/addons/hr_holidays/report/available_holidays.py @@ -19,71 +19,3 @@ # ############################################################################## -from osv import fields, osv -import tools - -class available_holidays_report(osv.osv): - _name = "available.holidays.report" - _auto = False - _columns = { - 'date': fields.date('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), - 'employee_id': fields.many2one ('hr.employee', "Employee's Name", readonly=True), - 'category_id': fields.many2one('hr.employee.category', "Category's Name", 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), - 'remaining_leave': fields.float('Remaining Leaves', readonly=True), - 'department_id': fields.many2one('hr.department', 'Department', readonly=True), - 'user_id': fields.many2one('res.users', 'User', readonly=True), - 'state': fields.selection([('draft', 'Draft'), - ('confirm', 'Waiting Validation'), - ('refuse', 'Refused'), - ('validate', 'Validated'), - ('cancel', 'Cancelled')] - ,'State', readonly=True), - } - def init(self, cr): - tools.drop_view_if_exists(cr, 'available_holidays_report') - cr.execute(""" - 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, - to_char(s.create_date, 'YYYY-MM-DD') as day, - h.employee_id as employee_id, - h.category_id as category_id, - h.user_id as user_id, - h.department_id, - h.state as state, - h.holiday_status_id as holiday_status_id, - 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' - and s.active <> 'f' - 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'), to_char(s.create_date, 'YYYY-MM-DD'), h.user_id,h.state, h.category_id, h.department_id - - )""") - -available_holidays_report() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_holidays/report/available_holidays_view.xml b/addons/hr_holidays/report/available_holidays_view.xml index 3fc3289fdcd..fa04c0ed784 100644 --- a/addons/hr_holidays/report/available_holidays_view.xml +++ b/addons/hr_holidays/report/available_holidays_view.xml @@ -2,115 +2,22 @@ - - - - available.holidays.report.tree - available.holidays.report - tree - - - - - - - - - - - - - - - - - - - - - available.holidays.report.graph - available.holidays.report - graph - - - - - - - - - - - available.holidays.report.search - available.holidays.report - search - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Leaves Analysis - available.holidays.report + + hr.holidays form - tree,graph - {'search_default_month':1,'search_default_user':1,'group_by':[], 'group_by_no_leaf':1} - + tree,form + + {'search_default_group_employee': 1, 'search_default_group_type': 1} + [('holiday_type','=','employee')] + - - - tree - - - + - - - graph - - - - - diff --git a/addons/hr_holidays/security/ir.model.access.csv b/addons/hr_holidays/security/ir.model.access.csv index 39229a6f3e6..940b0f06447 100644 --- a/addons/hr_holidays/security/ir.model.access.csv +++ b/addons/hr_holidays/security/ir.model.access.csv @@ -5,5 +5,3 @@ "access_hr_holydays_status_employee","hr.holidays.status employee","model_hr_holidays_status","base.group_user",1,0,0,0 "access_hr_holidays_remain_user","hr.holidays.ramain.user","model_hr_holidays_remaining_leaves_user","base.group_hr_user",1,1,1,1 "access_resource_calendar_leaves_manager","resource_calendar_leaves_manager","resource.model_resource_calendar_leaves","base.group_hr_manager",1,1,1,1 -"access_available_holidays_report_user","hr.available.holidays.report.user","model_available_holidays_report","base.group_hr_user",1,1,1,1 -"access_available_holidays_report_employee","hr.available.holidays.report.employee","model_available_holidays_report","base.group_user",1,0,0,0