summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVishnu Thuletiya <vtu@odoo.com>2020-03-17 04:38:35 +0000
committerBarad Mahendra <mba@openerp.com>2020-03-20 09:44:34 +0000
commit8fdb247d7cfcfe89bab826c164c8d993bc6b789e (patch)
treeb3ed2eabe2870909beeef6f127d7dd6d1756c24b
parent012678bf2798c749cfc918e3e3db2c04e39783cc (diff)
[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>
-rw-r--r--addons/hr_holidays/models/hr_leave.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/addons/hr_holidays/models/hr_leave.py b/addons/hr_holidays/models/hr_leave.py
index 25bf85e595d..0ad2618177b 100644
--- a/addons/hr_holidays/models/hr_leave.py
+++ b/addons/hr_holidays/models/hr_leave.py
@@ -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