shift_leave_wizard.py 978 Bytes
Newer Older
François C. committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
# -*- coding: utf-8 -*-
# Copyright (C) 2016-Today: La Louve (<http://www.lalouve.net/>)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import api, fields, models, _
from openerp.exceptions import ValidationError


class ShiftLeaveWizard(models.TransientModel):
    _inherit = 'shift.leave.wizard'

    @api.multi
    def button_confirm(self):
        self.ensure_one()

        leave = self.leave_id
        if not self._context.get('bypass_non_draft_confirm', False) and \
                leave.state != 'draft':
            raise ValidationError(_(
                "You can not confirm a leave in a non draft state."))

        if leave.non_defined_type and leave.non_defined_leave:
            leave.update_registration_template_based_non_define_leave()
        else:
            super(ShiftLeaveWizard, self).button_confirm()
            leave.update_info_anticipated_leave()