[FIX] hr_holidays: fix allocation without validation
In hr_holidays, when the time off type has the following settings: - Requires allocation: Yes - Employee Requests: Not allowed An allocation created with this time off type still requires to be validated. This commit removes the need to validate an allocation created with the time off type described above. task-3004313 closes odoo/odoo#106337 X-original-commit: c98e1280aee2f31e6dbf3f52dac47cf020c628d2 Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
committed by
Kevin Baptiste
parent
d1eab39ec3
commit
d61af003e1
@@ -627,15 +627,16 @@ class HolidaysAllocation(models.Model):
|
||||
return True
|
||||
|
||||
def action_confirm(self):
|
||||
if self.filtered(lambda holiday: holiday.state != 'draft'):
|
||||
if self.filtered(lambda holiday: holiday.state != 'draft' and holiday.validation_type != 'no'):
|
||||
raise UserError(_('Allocation request must be in Draft state ("To Submit") in order to confirm it.'))
|
||||
res = self.write({'state': 'confirm'})
|
||||
self.activity_update()
|
||||
self.filtered(lambda holiday: holiday.validation_type == 'no').action_validate()
|
||||
return res
|
||||
|
||||
def action_validate(self):
|
||||
current_employee = self.env.user.employee_id
|
||||
if any(holiday.state != 'confirm' for holiday in self):
|
||||
if any(holiday.state != 'confirm' and holiday.validation_type != 'no' for holiday in self):
|
||||
raise UserError(_('Allocation request must be confirmed in order to approve it.'))
|
||||
|
||||
self.write({
|
||||
|
||||
@@ -81,7 +81,7 @@ class HolidaysType(models.Model):
|
||||
Not Allowed: User cannot request an allocation.""")
|
||||
allocation_validation_type = fields.Selection([
|
||||
('officer', 'Approved by Time Off Officer'),
|
||||
('no', 'No validation needed')], default='officer', string='Approval',
|
||||
('no', 'No validation needed')], default='no', string='Approval',
|
||||
compute='_compute_allocation_validation_type', store=True, readonly=False,
|
||||
help="""Select the level of approval needed in case of request by employee
|
||||
- No validation needed: The employee's request is automatically approved.
|
||||
|
||||
@@ -166,9 +166,7 @@
|
||||
('holiday_status_id.employee_requests', '=', 'yes'),
|
||||
('holiday_type', '=', 'employee'),
|
||||
'|',
|
||||
'&',
|
||||
('employee_id.user_id', '=', user.id),
|
||||
('state', '!=', 'validate'),
|
||||
('employee_id.user_id', '=', user.id),
|
||||
'&',
|
||||
('validation_type', '=', 'officer'),
|
||||
('employee_id.leave_manager_id', '=', user.id),
|
||||
|
||||
@@ -52,7 +52,6 @@ export class TimeOffCalendarController extends CalendarController {
|
||||
|
||||
newAllocationRequest() {
|
||||
const context = {
|
||||
'default_state': 'confirm',
|
||||
'form_view_ref': 'hr_holidays.hr_leave_allocation_view_form_dashboard',
|
||||
};
|
||||
if (this.employeeId) {
|
||||
|
||||
@@ -18,6 +18,7 @@ class TestAccrualAllocations(TestHrHolidaysCommon):
|
||||
'name': 'Paid Time Off',
|
||||
'time_type': 'leave',
|
||||
'requires_allocation': 'yes',
|
||||
'allocation_validation_type': 'officer',
|
||||
})
|
||||
|
||||
def setAllocationCreateDate(self, allocation_id, date):
|
||||
|
||||
@@ -45,6 +45,7 @@ class TestHolidaysOvertime(TransactionCase):
|
||||
'company_id': cls.company.id,
|
||||
'requires_allocation': 'yes',
|
||||
'employee_requests': 'yes',
|
||||
'allocation_validation_type': 'officer',
|
||||
'overtime_deductible': True,
|
||||
})
|
||||
|
||||
@@ -183,6 +184,7 @@ class TestHolidaysOvertime(TransactionCase):
|
||||
'company_id': self.company.id,
|
||||
'requires_allocation': 'yes',
|
||||
'employee_requests': 'yes',
|
||||
'allocation_validation_type': 'officer',
|
||||
'overtime_deductible': False,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user