Skip to content
Snippets Groups Projects
Commit a270267c authored by Thomas Lefebvre (thle)'s avatar Thomas Lefebvre (thle)
Browse files

[FIX] hr_holidays: remove employee requests must remove validation type


Steps to reproduce:
- create a time off type;
- select 'Extra Days Requests Allowed' for 'Employee Requests';
- select 'Approved by Time Off Officer' for Approval;
- choose a Responsible Time Off Officer;
- change the select for 'Employee Requests' and select 'Not Allowed';
- create an allocation for an employee with this type.

Issue:
The allocation is blocked at step 'TO APPROVE'.

Cause:
Even if we choose `no` for `employee_requests`,
the `allocation_validation_type` always contains `officer`.

Solution:
We have to test the `employee_requests` field during the
validation action

opw-3264758

closes odoo/odoo#119013

Signed-off-by: default avatarKevin Baptiste <kba@odoo.com>
parent 2b80e84d
No related branches found
No related tags found
No related merge requests found
......@@ -646,12 +646,14 @@ class HolidaysAllocation(models.Model):
validated_holidays = self.filtered(lambda holiday: holiday.state == 'validate')
res = (self - validated_holidays).write({'state': 'confirm'})
self.activity_update()
self.filtered(lambda holiday: holiday.validation_type == 'no' and holiday.state != 'validate').action_validate()
no_employee_requests = [holiday.id for holiday in self.sudo() if holiday.holiday_status_id.employee_requests == 'no']
self.filtered(lambda holiday: (holiday.id in no_employee_requests or holiday.validation_type == 'no') and holiday.state != 'validate').action_validate()
return res
def action_validate(self):
current_employee = self.env.user.employee_id
if any(holiday.state != 'confirm' and holiday.validation_type != 'no' for holiday in self):
no_employee_requests = [holiday.id for holiday in self.sudo() if holiday.holiday_status_id.employee_requests == 'no']
if any((holiday.state != 'confirm' and holiday.id not in no_employee_requests and holiday.validation_type != 'no') for holiday in self):
raise UserError(_('Allocation request must be confirmed in order to approve it.'))
self.write({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment