From a1949ca541d760462add25995f139d1fb59f27d8 Mon Sep 17 00:00:00 2001 From: rupa-odoo Date: Fri, 30 Jun 2023 16:41:29 +0530 Subject: [PATCH] [IMP] hr_holidays: improve reports ux Before this commit if we go to the Time off and go to reporting in that select the to employee there are graph , calendar, pivot views and there are two default filter active employee , Employee > Type . And After that when we go to to type there are list, pivot view and by default there are 4 filter to the list view of the to type and in list view there is button. Improvements : To Employee : Add the List view and make it default. And make Current year by default. To Type : Add the graph view and make it default. Made changes in the filter add Time off, Allocations in that filter. Remove that button and use action method to the record. task-3389174 closes odoo/odoo#127034 Related: odoo/upgrade#4907 Signed-off-by: Sofie Gvaladze (sgv) --- addons/hr_holidays/report/hr_leave_report.py | 44 ++-------- .../hr_holidays/report/hr_leave_reports.xml | 85 ++++++------------- .../hr_holidays/views/hr_holidays_views.xml | 2 +- addons/hr_holidays/views/hr_leave_views.xml | 45 +++++++++- 4 files changed, 76 insertions(+), 100 deletions(-) diff --git a/addons/hr_holidays/report/hr_leave_report.py b/addons/hr_holidays/report/hr_leave_report.py index d5f9cc273e1..07aa2ab271c 100644 --- a/addons/hr_holidays/report/hr_leave_report.py +++ b/addons/hr_holidays/report/hr_leave_report.py @@ -11,11 +11,8 @@ class LeaveReport(models.Model): _auto = False _order = "date_from DESC, employee_id" - active = fields.Boolean(readonly=True) employee_id = fields.Many2one('hr.employee', string="Employee", readonly=True) leave_id = fields.Many2one('hr.leave', string="Time Off Request", readonly=True) - allocation_id = fields.Many2one('hr.leave.allocation', string="Allocation Request", readonly=True) - active_employee = fields.Boolean(readonly=True) name = fields.Char('Description', readonly=True) number_of_days = fields.Float('Number of Days', readonly=True) leave_type = fields.Selection([ @@ -47,20 +44,16 @@ class LeaveReport(models.Model): self._cr.execute(""" CREATE or REPLACE view hr_leave_report as ( SELECT row_number() over(ORDER BY leaves.employee_id) as id, - leaves.allocation_id as allocation_id, leaves.leave_id as leave_id, + leaves.leave_id as leave_id, leaves.employee_id as employee_id, leaves.name as name, - leaves.active_employee as active_employee, leaves.active as active, leaves.number_of_days as number_of_days, leaves.leave_type as leave_type, leaves.category_id as category_id, leaves.department_id as department_id, leaves.holiday_status_id as holiday_status_id, leaves.state as state, leaves.holiday_type as holiday_type, leaves.date_from as date_from, leaves.date_to as date_to, leaves.company_id from (select - allocation.active as active, - allocation.id as allocation_id, null as leave_id, allocation.employee_id as employee_id, - employee.active as active_employee, allocation.private_name as name, allocation.number_of_days as number_of_days, allocation.category_id as category_id, @@ -74,12 +67,11 @@ class LeaveReport(models.Model): allocation.employee_company_id as company_id from hr_leave_allocation as allocation inner join hr_employee as employee on (allocation.employee_id = employee.id) + where employee.active IS True AND + allocation.active IS True union all select - request.active as active, - null as allocation_id, request.id as leave_id, request.employee_id as employee_id, - employee.active as active_employee, request.private_name as name, (request.number_of_days * -1) as number_of_days, request.category_id as category_id, @@ -93,41 +85,17 @@ class LeaveReport(models.Model): request.employee_company_id as company_id from hr_leave as request inner join hr_employee as employee on (request.employee_id = employee.id) + where employee.active IS True ) leaves ); """) - @api.model - def action_time_off_analysis(self): - domain = [('holiday_type', '=', 'employee')] - - if self.env.context.get('active_ids'): - domain = expression.AND([ - domain, - [('employee_id', 'in', self.env.context.get('active_ids', []))] - ]) - - return { - 'name': _('Time Off Analysis'), - 'type': 'ir.actions.act_window', - 'res_model': 'hr.leave.report', - 'view_mode': 'tree,pivot,form', - 'search_view_id': [self.env.ref('hr_holidays.view_hr_holidays_filter_report').id], - 'domain': domain, - 'context': { - 'search_default_group_type': True, - 'search_default_year': True, - 'search_default_validated': True, - 'search_default_active_employee': True, - } - } - def action_open_record(self): self.ensure_one() return { 'type': 'ir.actions.act_window', 'view_mode': 'form', - 'res_id': self.leave_id.id if self.leave_id else self.allocation_id.id, - 'res_model': 'hr.leave' if self.leave_id else 'hr.leave.allocation', + 'res_id': self.leave_id.id, + 'res_model': 'hr.leave', } diff --git a/addons/hr_holidays/report/hr_leave_reports.xml b/addons/hr_holidays/report/hr_leave_reports.xml index 5ffac9a821e..e50a8139ee5 100644 --- a/addons/hr_holidays/report/hr_leave_reports.xml +++ b/addons/hr_holidays/report/hr_leave_reports.xml @@ -11,17 +11,14 @@ - + + - - - - @@ -39,77 +36,51 @@ report.hr.holidays.report.leave_all.tree hr.leave.report - -