[FIX] hr_holidays: is absent search
To Reproduce ============ - go to employees app and filter by `Absent is Yes` then by `Absent is No` some employees are present in both filters which is not logical Problem ======= the search method on `is_absent` field always performs the search `ids in absent_ids` no matter what are the operator and the value Solution ======== use the `operator` argument in the searching opw-3205967 closes odoo/odoo#115443 X-original-commit: 89a762ec463efd936c5d60a483f3cac876724b7e Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com> Signed-off-by: abla001 <abla@odoo.com>
This commit is contained in:
@@ -180,7 +180,10 @@ class HrEmployeeBase(models.AbstractModel):
|
||||
('date_from', '<=', today_end),
|
||||
('date_to', '>=', today_start),
|
||||
])
|
||||
return [('id', 'in', holidays.mapped('employee_id').ids)]
|
||||
op = 'not in'
|
||||
if (operator == '=' and value) or (operator == '!=' and not value):
|
||||
op = 'in'
|
||||
return [('id', op, holidays.mapped('employee_id').ids)]
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
|
||||
@@ -103,3 +103,18 @@ class TestOutOfOfficePerformance(TestHrHolidaysCommon, TransactionCaseWithUserDe
|
||||
self.leave.write({'state': 'validate'})
|
||||
with self.assertQueryCount(__system__=2, demo=2):
|
||||
self.assertEqual(self.hr_partner.im_status, 'leave_offline')
|
||||
|
||||
def test_search_absent_employee(self):
|
||||
present_employees = self.env['hr.employee'].search([('is_absent', '!=', 'True')])
|
||||
absent_employees = self.env['hr.employee'].search([('is_absent', '=', 'True')])
|
||||
today_date = datetime.utcnow().date()
|
||||
holidays = self.env['hr.leave'].sudo().search([
|
||||
('employee_id', '!=', False),
|
||||
('state', 'not in', ['cancel', 'refuse']),
|
||||
('date_from', '<=', today_date),
|
||||
('date_to', '>=', today_date),
|
||||
])
|
||||
for employee in present_employees:
|
||||
self.assertFalse(employee in holidays.employee_id)
|
||||
for employee in absent_employees:
|
||||
self.assertFalse(employee not in holidays.employee_id)
|
||||
|
||||
Reference in New Issue
Block a user