Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions hr_holidays_google_calendar/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
"name": "Holidays Google Calendar",
"version": "19.0.1.0.0",
"version": "20.0.1.0.0",
"category": "Human Resources",
"summary": "Suppress Google Calendar invitations when approving time off",
"author": "ADHOC SA",
Expand All @@ -31,7 +31,7 @@
],
"data": [],
"demo": [],
"installable": False,
"installable": True,
"auto_install": True,
"application": False,
}
42 changes: 42 additions & 0 deletions hr_holidays_google_calendar/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_holidays_google_calendar
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-10-23 18:13+0000\n"
"PO-Revision-Date: 2026-10-23 18:13+0000\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"

#. module: hr_holidays_google_calendar
#: model:ir.model,name:hr_holidays_google_calendar.model_calendar_event
msgid "Calendar Event"
msgstr "Evento del calendario"

#. module: hr_holidays_google_calendar
#: model:ir.model.fields,field_description:hr_holidays_google_calendar.field_calendar_event__display_name
msgid "Display Name"
msgstr "Nombre en pantalla"

#. module: hr_holidays_google_calendar
#: model:ir.module.module,shortdesc:base.module_hr_holidays_google_calendar
msgid "Holidays Google Calendar"
msgstr "Ausencias Google Calendar"

#. module: hr_holidays_google_calendar
#: model:ir.model.fields,field_description:hr_holidays_google_calendar.field_calendar_event__id
msgid "ID"
msgstr ""

#. module: hr_holidays_google_calendar
#: model:ir.module.module,summary:base.module_hr_holidays_google_calendar
msgid "Suppress Google Calendar invitations when approving time off"
msgstr "Suprime las invitaciones de Google Calendar al aprobar ausencias"
16 changes: 13 additions & 3 deletions hr_holidays_google_calendar/i18n/hr_holidays_google_calendar.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0+e\n"
"Project-Id-Version: Odoo Server 20.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-06-17 15:20+0000\n"
"PO-Revision-Date: 2026-06-17 15:20+0000\n"
"POT-Creation-Date: 2026-10-23 18:13+0000\n"
"PO-Revision-Date: 2026-10-23 18:13+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand All @@ -25,7 +25,17 @@ msgstr ""
msgid "Display Name"
msgstr ""

#. module: hr_holidays_google_calendar
#: model:ir.module.module,shortdesc:base.module_hr_holidays_google_calendar
msgid "Holidays Google Calendar"
msgstr ""

#. module: hr_holidays_google_calendar
#: model:ir.model.fields,field_description:hr_holidays_google_calendar.field_calendar_event__id
msgid "ID"
msgstr ""

#. module: hr_holidays_google_calendar
#: model:ir.module.module,summary:base.module_hr_holidays_google_calendar
msgid "Suppress Google Calendar invitations when approving time off"
msgstr ""
7 changes: 4 additions & 3 deletions hr_holidays_google_calendar/models/calendar_event.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
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):
# Odoo 20 still calls this with the old signature in google_event_sync.py:68
# (no `calendar`), so the override forwards whatever it gets instead of binding it.
def _google_insert(self, *args, **kwargs):
# 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)
return super()._google_insert(*args, **kwargs)
1 change: 1 addition & 0 deletions hr_holidays_google_calendar/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_calendar_event
59 changes: 59 additions & 0 deletions hr_holidays_google_calendar/tests/test_calendar_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from datetime import timedelta
from unittest.mock import patch

from odoo import fields
from odoo.addons.google_calendar.models.google_event_sync import GoogleEventSync
from odoo.tests.common import TransactionCase


class TestCalendarEventGoogleInsert(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
now = fields.Datetime.now()
cls.event = cls.env["calendar.event"].create(
{
"name": "Time off",
"start": now,
"stop": now + timedelta(hours=1),
}
)

def _forward(self, context, *args, **kwargs):
"""Call the override with the parent replaced, and return what the parent got."""
seen = []

def _parent(records, *parent_args, **parent_kwargs):
seen.append((records.env.context, parent_args, parent_kwargs))

# Not autospec: after_commit wraps the parent, so autospec would enforce
# its signature and reject the very call shape this test covers.
with patch.object(GoogleEventSync, "_google_insert", _parent):
self.event.with_context(**context)._google_insert(*args, **kwargs)
self.assertEqual(len(seen), 1, "the override must call its parent exactly once")
return seen[0]

def test_google_insert_forwards_every_call_shape(self):
"""The override forwards each call Odoo 20 makes, and suppresses the Google
notification only when hr_holidays asked not to notify the attendees.
"""
service = self.env["google.service"]
values = {"summary": "Time off"}

with self.subTest("confirming a draft event does not break"):
# google_calendar/models/google_event_sync.py:68 still calls without `calendar`
context, args, kwargs = self._forward({}, service, values, timeout=3)
self.assertEqual(args, (service, values))
self.assertEqual(kwargs, {"timeout": 3})
self.assertNotIn("send_updates", context)

with self.subTest("the call with a calendar reaches the parent untouched"):
context, args, kwargs = self._forward({}, service, "primary", values, timeout=3)
self.assertEqual(args, (service, "primary", values))
self.assertEqual(kwargs, {"timeout": 3})
self.assertNotIn("send_updates", context)

with self.subTest("an approved time off does not notify attendees on Google"):
context, args, kwargs = self._forward({"no_mail_to_attendees": True}, service, "primary", values)
self.assertFalse(context["send_updates"])
self.assertEqual(args, (service, "primary", values))
Loading