Time Off To Defer leaves_to_defer = self.env['hr.leave'].search([ ('payslip_state', '=', 'blocked'), ('state', '=', 'validate'), ('employee_company_id', 'in', self.env.companies.ids), ]) if leaves_to_defer: warning_count = len(leaves_to_defer) warning_action = 'hr_payroll_holidays.hr_leave_action_open_to_defer' Time Off Without Joined Document leaves_no_document = self.env['hr.leave'].search([ ('state', 'not in', ['refuse', 'validate']), ('leave_type_support_document', '=', True), ('attachment_ids', '=', False), ('employee_company_id', 'in', self.env.companies.ids), ]) if leaves_no_document: warning_count = len(leaves_no_document) warning_records = leaves_no_document Time Off Not Related To An Allocation leaves_no_allocation_ids = [] employees = self.env['hr.employee'].search([('company_id', 'in', self.env.companies.ids)]) consumed_leaves = employees._get_consumed_leaves(leave_types=self.env['hr.leave.type'].search([ ('requires_allocation', '=', True), ('allows_negative', '=', False), ]))[1] for employee in consumed_leaves: to_recheck_leaves_per_leave_type = consumed_leaves[employee] for holiday_status_id in to_recheck_leaves_per_leave_type: for end_dates in to_recheck_leaves_per_leave_type[holiday_status_id]['excess_days']: leave_id = to_recheck_leaves_per_leave_type[holiday_status_id]['excess_days'][end_dates]['leave_id'] leaves_no_allocation_ids.append(leave_id) if leaves_no_allocation_ids: warning_count = len(leaves_no_allocation_ids) warning_records = self.env['hr.leave'].search([('id', 'in', leaves_no_allocation_ids)])