<commit_before># -*- coding: utf-8 -*-
# Copyright 2016 KMEE INFORMATICA LTDA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from datetime import datetime
from openerp import api, fields, models, _
from openerp.exceptions import Warning as UserError


class HrHolidays(models.Model):

    _inherit = 'hr.holidays'

    message = fields.Char(
        string=u"Mensagem",
        related='holiday_status_id.message',
    )
<commit_msg>[ADD] funcao de validacao de dias de acordo com tipo de holiday<commit_after># -*- coding: utf-8 -*-
# Copyright 2016 KMEE INFORMATICA LTDA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from datetime import datetime
from openerp import api, fields, models, _
from openerp.exceptions import Warning as UserError


class HrHolidays(models.Model):

    _inherit = 'hr.holidays'

    message = fields.Char(
        string=u"Mensagem",
        related='holiday_status_id.message',
    )

    def validate_days_status_id(self):
        resource_calendar_obj = self.env['resource.calendar']
        for record in self:
            if record.holiday_status_id.type_day:
                if record.holiday_status_id.type_day == u'uteis':
                   if resource_calendar_obj.retorna_num_dias_uteis(
                            datetime.strptime(
                                record.date_from,"%Y-%m-%d %H:%M:%S"),
                            datetime.strptime(
                                record.date_to,"%Y-%m-%d %H:%M:%S")
                    ) > record.holiday_status_id.days_limit:
                        raise UserError(_("Número de dias excedido!"))
                if record.holiday_status_id.type_day == u'corridos':
                    if record.number_of_days_temp > \
                            record.holiday_status_id.days_limit:
                        raise UserError(_("Número de dias excedido!"))

    @api.multi
    def holidays_confirm(self):
        self.validate_days_status_id()
        return super(HrHolidays, self).holidays_confirm()

{'fraction_non_alphanumeric': 0.10221130221130222, 'fraction_numerical': 0.0068796068796068794, 'mean_word_length': 2.236883942766296, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4656134', 'n_tokens_mistral': 645, 'n_tokens_neox': 612, 'n_words': 130}