<commit_before># Copyright 2018 elego Software Solutions GmbH - <NAME>
# Copyright 2018 initOS GmbH - <NAME>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from datetime import datetime, timedelta
from dateutil import easter

from odoo import _, api, fields, models
from . import hr_holidays_public_generator
from odoo.exceptions import UserError

hr_holidays_public_generator.COUNTRY_GENERATORS.append("DE")


class HrHolidaysPublicGenerator(models.TransientModel):
    _inherit = 'hr.holidays.public.generator'

    @api.model
    def calculate_easter_sunday(self, year):
        return easter.easter(year)

    @api.model
    def calculate_new_good_friday(self, easter):
        good_friday = easter - timedelta(days=2)
        return fields.Date.to_string(good_friday)

    @api.model
    def calculate_easter_monday(self, easter):
        easter_monday = easter + timedelta(days=1)
        return fields.Date.to_string(easter_monday)

    @api.model
    def calculate_ascension_day(self, easter):
        ascension_day = easter + timedelta(days=39)
        return fields.Date.to_string(ascension_day)

    @api.model
    def calculate_whit_monday(self, easter):
        whit_monday = easter + timedelta(days=50)
        return fields.Date.to_string(whit_monday)

    @api.model
    def calculate_corpus_christi(self, easter):
        corpus_christi = easter + timedelta(days=60)
        return fields.Date.to_string(corpus_christi)

    @api.model
    def calculate_floating_holidays(self, existing_holidays):
        public_holiday_line_obj = self.env['hr.holidays.public.line']
        easter = self.calculate_easter_sunday(self.year)

        public_holiday_line_obj.create({'name': _('Good Friday'),
                                        'date':
                                            self.calculate_new_good_friday(
                                                easter),
                                        'variable_date': True,
                                        'year_id': existing_holidays.id})
        public_holiday_line_obj.create({'name': _('Easter Sunday'),
                                        'date': fields.Date.to_string(easter),
                                        'variable_date': True,
                                        'year_id': existing_holidays.id})

        public_holiday_line_obj.create({'name': _('Easter Monday'),
                                        'date':
                                            self.calculate_easter_monday(
                                                easter),
                                        'variable_date': True,
                                        'year_id': existing_holidays.id})
        public_holiday_line_obj.create({'name': _('Ascension Day'),
                                        'date':
                                            self.calculate_ascension_day(
                                                easter),
                                        'variable_date': True,
                                        'year_id': existing_holidays.id})

        public_holiday_line_obj.create({'name': _('Whit Monday'),
                                        'date':
                                            self.calculate_whit_monday(
                                                easter),
                                        'variable_date': True,
                                        'year_id': existing_holidays.id})

    @api.model
    def get_state_ids(self, codes=[]):
        """
        :codes: list of states' codes
        Returns states ids in :codes:
        """
        state_ids = self.env['res.country.state'].search([
            ('code', 'in', codes)
        ])<commit_msg>[IMP] add country id when query states<commit_after># Copyright 2018 elego Software Solutions GmbH - <NAME>
# Copyright 2018 initOS GmbH - <NAME>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from datetime import datetime, timedelta
from dateutil import easter

from odoo import _, api, fields, models
from . import hr_holidays_public_generator
from odoo.exceptions import UserError

hr_holidays_public_generator.COUNTRY_GENERATORS.append("DE")


class HrHolidaysPublicGenerator(models.TransientModel):
    _inherit = 'hr.holidays.public.generator'

    @api.model
    def calculate_easter_sunday(self, year):
        return easter.easter(year)

    @api.model
    def calculate_new_good_friday(self, easter):
        good_friday = easter - timedelta(days=2)
        return fields.Date.to_string(good_friday)

    @api.model
    def calculate_easter_monday(self, easter):
        easter_monday = easter + timedelta(days=1)
        return fields.Date.to_string(easter_monday)

    @api.model
    def calculate_ascension_day(self, easter):
        ascension_day = easter + timedelta(days=39)
        return fields.Date.to_string(ascension_day)

    @api.model
    def calculate_whit_monday(self, easter):
        whit_monday = easter + timedelta(days=50)
        return fields.Date.to_string(whit_monday)

    @api.model
    def calculate_corpus_christi(self, easter):
        corpus_christi = easter + timedelta(days=60)
        return fields.Date.to_string(corpus_christi)

    @api.model
    def calculate_floating_holidays(self, existing_holidays):
        public_holiday_line_obj = self.env['hr.holidays.public.line']
        easter = self.calculate_easter_sunday(self.year)

        public_holiday_line_obj.create({'name': _('Good Friday'),
                                        'date':
                                            self.calculate_new_good_friday(
                                                easter),
                                        'variable_date': True,
                                        'year_id': existing_holidays.id})
        public_holiday_line_obj.create({'name': _('Easter Sunday'),
                                        'date': fields.Date.to_string(easter),
                                        'variable_date': True,
                                        'year_id': existing_holidays.id})

        public_holiday_line_obj.create({'name': _('Easter Monday'),
                                        'date':
                                            self.calculate_easter_monday(
                                                easter),
                                        'variable_date': True,
                                        'year_id': existing_holidays.id})
        public_holiday_line_obj.create({'name': _('Ascension Day'),
                                        'date':
                                            self.calculate_ascension_day(
                                                easter),
                                        'variable_date': True,
                                        'year_id': existing_holidays.id})

        public_holiday_line_obj.create({'name': _('Whit Monday'),
                                        'date':
                                            self.calculate_whit_monday(
                                                easter),
                                        'variable_date': True,
                                        'year_id': existing_holidays.id})

    @api.model
    def get_state_ids(self, codes=[]):
        """
        :codes: list of states' codes
        Returns states ids in :codes:
        """
        country = self.env.ref('base.de')
        state_ids = self.env['res.country.state'].search([
            ('code', 'in', codes), ('country_id', '=', country.id)
        ])
{'fraction_non_alphanumeric': 0.09017904160084254, 'fraction_numerical': 0.004739336492890996, 'mean_word_length': 1.4883720930232558, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 62, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7057348', 'n_tokens_mistral': 1973, 'n_tokens_neox': 1911, 'n_words': 354}