diff --git a/hr_holidays_google_calendar/__init__.py b/hr_holidays_google_calendar/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/hr_holidays_google_calendar/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/hr_holidays_google_calendar/__manifest__.py b/hr_holidays_google_calendar/__manifest__.py new file mode 100644 index 0000000..20655ba --- /dev/null +++ b/hr_holidays_google_calendar/__manifest__.py @@ -0,0 +1,37 @@ +############################################################################## +# +# Copyright (C) 2024 ADHOC SA (http://www.adhoc.com.ar) +# All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{ + "name": "Holidays Google Calendar", + "version": "19.0.1.0.0", + "category": "Human Resources", + "summary": "Suppress Google Calendar invitations when approving time off", + "author": "ADHOC SA", + "website": "www.adhoc.com.ar", + "license": "AGPL-3", + "depends": [ + "hr_holidays", + "google_calendar", + ], + "data": [], + "demo": [], + "installable": True, + "auto_install": True, + "application": False, +} diff --git a/hr_holidays_google_calendar/models/__init__.py b/hr_holidays_google_calendar/models/__init__.py new file mode 100644 index 0000000..ba757cb --- /dev/null +++ b/hr_holidays_google_calendar/models/__init__.py @@ -0,0 +1 @@ +from . import calendar_event diff --git a/hr_holidays_google_calendar/models/calendar_event.py b/hr_holidays_google_calendar/models/calendar_event.py new file mode 100644 index 0000000..8c44685 --- /dev/null +++ b/hr_holidays_google_calendar/models/calendar_event.py @@ -0,0 +1,14 @@ +from odoo import models +from odoo.addons.google_calendar.models.google_sync import TIMEOUT + + +class CalendarEvent(models.Model): + _inherit = "calendar.event" + + def _google_insert(self, google_service, values, timeout=TIMEOUT): + # When hr_holidays creates a leave event it sets no_mail_to_attendees=True, + # meaning Odoo itself must not notify attendees. Honour that restriction in + # Google Calendar too by suppressing the sendUpdates notification. + if self.env.context.get("no_mail_to_attendees"): + self = self.with_context(send_updates=False) + return super()._google_insert(google_service, values, timeout=timeout) diff --git a/hr_holidays_microsoft_calendar/__init__.py b/hr_holidays_microsoft_calendar/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/hr_holidays_microsoft_calendar/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/hr_holidays_microsoft_calendar/__manifest__.py b/hr_holidays_microsoft_calendar/__manifest__.py new file mode 100644 index 0000000..0cd4f93 --- /dev/null +++ b/hr_holidays_microsoft_calendar/__manifest__.py @@ -0,0 +1,37 @@ +############################################################################## +# +# Copyright (C) 2024 ADHOC SA (http://www.adhoc.com.ar) +# All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{ + "name": "Holidays Microsoft Calendar", + "version": "19.0.1.0.0", + "category": "Human Resources", + "summary": "Suppress Outlook invitations when approving time off", + "author": "ADHOC SA", + "website": "www.adhoc.com.ar", + "license": "AGPL-3", + "depends": [ + "hr_holidays", + "microsoft_calendar", + ], + "data": [], + "demo": [], + "installable": True, + "auto_install": True, + "application": False, +} diff --git a/hr_holidays_microsoft_calendar/models/__init__.py b/hr_holidays_microsoft_calendar/models/__init__.py new file mode 100644 index 0000000..ba757cb --- /dev/null +++ b/hr_holidays_microsoft_calendar/models/__init__.py @@ -0,0 +1 @@ +from . import calendar_event diff --git a/hr_holidays_microsoft_calendar/models/calendar_event.py b/hr_holidays_microsoft_calendar/models/calendar_event.py new file mode 100644 index 0000000..d03c1d7 --- /dev/null +++ b/hr_holidays_microsoft_calendar/models/calendar_event.py @@ -0,0 +1,15 @@ +from odoo import models + + +class CalendarEvent(models.Model): + _inherit = "calendar.event" + + def _microsoft_values(self, fields_to_sync, initial_values=()): + # When hr_holidays creates a leave event it sets no_mail_to_attendees=True, + # meaning Odoo itself must not notify attendees. Honour that restriction for + # Outlook too by removing attendees from the Graph API payload so Microsoft + # does not send invitation emails on its side. + values = super()._microsoft_values(fields_to_sync, initial_values) + if self.env.context.get("no_mail_to_attendees"): + values.pop("attendees", None) + return values