hr_holidays_cancel_leave.py 846 B

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo import fields, models, _
  4. from odoo.exceptions import ValidationError
  5. class HrHolidaysCancelLeave(models.TransientModel):
  6. _name = 'hr.holidays.cancel.leave'
  7. _description = 'Cancel Leave Wizard'
  8. leave_id = fields.Many2one('hr.leave', required=True)
  9. reason = fields.Text(required=True)
  10. def action_cancel_leave(self):
  11. self.ensure_one()
  12. self.leave_id._action_user_cancel(self.reason)
  13. return {
  14. 'type': 'ir.actions.client',
  15. 'tag': 'display_notification',
  16. 'params': {
  17. 'type': 'success',
  18. 'message': _("Your time off has been canceled."),
  19. 'next': {'type': 'ir.actions.act_window_close'},
  20. }
  21. }