[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) <rli@odoo.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,17 +110,14 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="act_hr_employee_holiday_request" model="ir.actions.act_window">
|
||||
<record id="act_hr_employee_holiday_request" model="ir.actions.server">
|
||||
<field name="name">Time off Analysis</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">hr.leave.report</field>
|
||||
<field name="model_id" ref="hr_holidays.model_hr_leave_report"/>
|
||||
<field name="binding_model_id" ref="hr.model_hr_employee"/>
|
||||
<field name="view_mode">tree,form,pivot</field>
|
||||
<field name="context">{
|
||||
'search_default_group_type': 1,
|
||||
'search_default_year': 1}</field>
|
||||
<field name="domain">[('holiday_type','=','employee')]</field>
|
||||
<field name="search_view_id" ref="view_hr_holidays_filter_report"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">
|
||||
action = model.action_time_off_analysis()
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user