[FIX] hr_holidays: Fix the wrong behavior of no-validation leave type
Currently when you create time off type with no validation and then create new time off request, save and status is approved. However, if you refuse the time off and reset to Draft and confirm it then status will be 'To approve' when it should be 'Approved'. So after this commit, on confirm of refused time off with validation type 'no validation' automatically move to the 'Approved' instead of 'To Approve'. closes odoo/odoo#48087 Taskid: 2206222 Closes: #47738 X-original-commit: 3d2391d350ea7ed572cf6818ab3f607c99fe0bf5 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
committed by
Barad Mahendra
parent
012678bf27
commit
8fdb247d7c
@@ -891,6 +891,10 @@ class HolidaysRequest(models.Model):
|
||||
if self.filtered(lambda holiday: holiday.state != 'draft'):
|
||||
raise UserError(_('Time off request must be in Draft state ("To Submit") in order to confirm it.'))
|
||||
self.write({'state': 'confirm'})
|
||||
holidays = self.filtered(lambda leave: leave.validation_type == 'no_validation')
|
||||
if holidays:
|
||||
# Automatic validation should be done in sudo, because user might not have the rights to do it by himself
|
||||
holidays.sudo().action_validate()
|
||||
self.activity_update()
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user