diff options
Diffstat (limited to 'addons/hr_holidays/wizard/hr_departure_wizard.py')
| -rw-r--r-- | addons/hr_holidays/wizard/hr_departure_wizard.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/addons/hr_holidays/wizard/hr_departure_wizard.py b/addons/hr_holidays/wizard/hr_departure_wizard.py new file mode 100644 index 00000000..784d4f3a --- /dev/null +++ b/addons/hr_holidays/wizard/hr_departure_wizard.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from datetime import datetime, timedelta + +from odoo import api, fields, models + + +class HrDepartureWizard(models.TransientModel): + _inherit = 'hr.departure.wizard' + + cancel_leaves = fields.Boolean("Cancel Future Leaves", default=True) + + def action_register_departure(self): + super(HrDepartureWizard, self).action_register_departure() + if self.cancel_leaves: + future_leaves = self.env['hr.leave'].search([('employee_id', '=', self.employee_id.id), + ('date_to', '>', self.departure_date), + ('state', 'not in', ['cancel', 'refuse'])]) + future_leaves.write({'state': 'cancel'}) |
