diff --git a/addons/resource/i18n/resource.pot b/addons/resource/i18n/resource.pot index 7d120650736..c7646ec2873 100644 --- a/addons/resource/i18n/resource.pot +++ b/addons/resource/i18n/resource.pot @@ -258,6 +258,12 @@ msgstr "" #. odoo-python #: code:addons/resource/models/resource.py:0 #, python-format +msgid "Impossible to switch calendar type for the default company schedule." +msgstr "" + +#. module: resource +#: code:addons/resource/models/resource.py:0 +#, python-format msgid "" "In a calendar with 2 weeks mode, all periods need to be in the sections." msgstr "" diff --git a/addons/resource/models/resource_calendar.py b/addons/resource/models/resource_calendar.py index 16fcfee5068..7627d9fc0b5 100644 --- a/addons/resource/models/resource_calendar.py +++ b/addons/resource/models/resource_calendar.py @@ -14,7 +14,7 @@ from pytz import timezone, utc from odoo import api, fields, models, _ from odoo.addons.base.models.res_partner import _tz_get -from odoo.exceptions import ValidationError +from odoo.exceptions import ValidationError, UserError from odoo.osv import expression from odoo.tools.float_utils import float_round @@ -184,6 +184,9 @@ class ResourceCalendar(models.Model): return float_round(hour_count / float(number_of_days), precision_digits=2) def switch_calendar_type(self): + if self == self.env.company.resource_calendar_id: + raise UserError(_('Impossible to switch calendar type for the default company schedule.')) + if not self.two_weeks_calendar: self.attendance_ids.unlink() self.attendance_ids = [