From 5b3509daaabfed3f73feab4c749e38bed75fe077 Mon Sep 17 00:00:00 2001 From: Kevin Baptiste Date: Wed, 18 Sep 2019 06:55:13 +0000 Subject: [PATCH] [FIX] hr_holidays: filter Time off Analysis on active ids Prior to this commit, the Time Off Analysis report was showing the leaves of all employees and not the ones selected. closes odoo/odoo#37048 Taskid: 2073345 Signed-off-by: Romain Libert (rli) --- addons/hr_holidays/report/hr_leave_report.py | 27 ++++++++++++++++++- .../hr_holidays/report/hr_leave_reports.xml | 15 +++++------ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/addons/hr_holidays/report/hr_leave_report.py b/addons/hr_holidays/report/hr_leave_report.py index 93862fc4934..f89d1a6eba3 100644 --- a/addons/hr_holidays/report/hr_leave_report.py +++ b/addons/hr_holidays/report/hr_leave_report.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models, tools +from odoo import api, fields, models, tools, _ +from odoo.osv import expression class LeaveReport(models.Model): @@ -96,3 +97,27 @@ class LeaveReport(models.Model): except Exception: # skip SpecialValue (e.g. for missing record or access right) pass + + + @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,form,pivot', + '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 + } + } diff --git a/addons/hr_holidays/report/hr_leave_reports.xml b/addons/hr_holidays/report/hr_leave_reports.xml index 9e48b10678d..c451fb36b1b 100644 --- a/addons/hr_holidays/report/hr_leave_reports.xml +++ b/addons/hr_holidays/report/hr_leave_reports.xml @@ -110,17 +110,14 @@ - + Time off Analysis - ir.actions.act_window - hr.leave.report + - tree,form,pivot - { - 'search_default_group_type': 1, - 'search_default_year': 1} - [('holiday_type','=','employee')] - + code + + action = model.action_time_off_analysis() +