[FIX] employee_requests: vehicle.delegation permission

This commit is contained in:
Samir Ladoui 2025-03-04 13:58:58 +01:00
parent 7974b95aaf
commit 65170c7e93
1 changed files with 3 additions and 3 deletions

View File

@ -64,14 +64,14 @@ class HrClearanceForm(models.Model):
employee_name = self.sudo().employee_id
if emp_custody:
# Check if employee has Employee Custody not in state Return done
employee_custody = self.env['custom.employee.custody'].search([('employee_id', '=', employee_name.id),
employee_custody = self.env['custom.employee.custody'].sudo().search([('employee_id', '=', employee_name.id),
('state', 'in', ['direct', 'admin', 'approve'])])
if len(employee_custody) > 0:
raise exceptions.Warning(_('Sorry, Can Not Clearance The Employee %s Has custody %s Not Return') % (
employee_name.name, len(employee_custody)))
if petty_cash_modules:
# Check if employee has Employee Petty Cash Payment not in state Return done
employee_petty_cash_payment = self.env['petty.cash'].search([('partner_id', '=', employee_name.user_id.partner_id.id),
employee_petty_cash_payment = self.env['petty.cash'].sudo().search([('partner_id', '=', employee_name.user_id.partner_id.id),
('state', 'in', ['submitted', 'running'])])
if len(employee_petty_cash_payment) > 0:
raise exceptions.Warning(_('Sorry, Can Not Clearance The Employee %s Has Petty Cash %s Not Return') % (
@ -79,7 +79,7 @@ class HrClearanceForm(models.Model):
if fleet:
# Check if employee has Employee fleet not in state Return done
employee_fleet = self.env['vehicle.delegation'].search([('employee_id', '=', employee_name.id),
employee_fleet = self.env['vehicle.delegation'].sudo().search([('employee_id', '=', employee_name.id),
('state', 'in', ['approve', 'in_progress'])])
if len(employee_fleet) > 0:
raise exceptions.Warning(_('Sorry, Can not Clearance The employee %s Has delegation vehicle %s Is Valid') % (