* Fixed an issue where accepting events from an external organizer would send emails to the all event attendees upon synchronization. * Corrected the data model for events where multiple Odoo users are attendees for the same event. Now, only one event is created in Odoo, with all the attendees on the same event. This conforms to Odoo's existing calendar event data model. * Updated the setting of the organizer field (user_id) on the calendar events upon synchronization. Previously, the organizer field was always set to the current user whose events were being synchronized. Now, it is set based on the ORGANIZER parameter of the iCalendar event, if present. If not present, it defaults to the current synchronizing user. In the case that the organizer is external, the user_id field is left blank.
55 lines
2.1 KiB
Python
55 lines
2.1 KiB
Python
from odoo.tests import TransactionCase
|
|
from unittest.mock import patch, MagicMock
|
|
from .common import CaldavTestCommon
|
|
from .test_calendar import _get_ics_path, _patch_caldav_with_events_from_ics
|
|
|
|
|
|
class TestExternalOrganizer(TransactionCase, CaldavTestCommon):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super().setUpClass()
|
|
cls.user = cls._generate_user(
|
|
"test",
|
|
caldav_username="test",
|
|
caldav_password="test",
|
|
caldav_url="https://example.com/calendar",
|
|
)
|
|
|
|
def test_external_organizer_event_sync(self):
|
|
"""Test that events with external organizers are handled correctly."""
|
|
# Setup mock for CalDAV client with our test ICS file
|
|
with _patch_caldav_with_events_from_ics(
|
|
[_get_ics_path("test_external_organizer.ics")], self.user
|
|
):
|
|
# Ensure caldav is enabled
|
|
self.user._compute_is_caldav_enabled()
|
|
# Sync events from the mock server
|
|
self.env["calendar.event"].poll_caldav_server()
|
|
|
|
# Find the synced event
|
|
event = self.env["calendar.event"].search(
|
|
[("caldav_uid", "=", "external-organizer-test-123")]
|
|
)
|
|
|
|
# Verify event was created
|
|
self.assertTrue(event, "Event should be created")
|
|
|
|
# Verify user_id is False for external organizer
|
|
self.assertFalse(
|
|
event.user_id,
|
|
"Event with external organizer should have user_id set to False",
|
|
)
|
|
|
|
# Verify the organizer's email is preserved in attendees
|
|
external_attendee = event.attendee_ids.filtered(
|
|
lambda a: a.email == "external.person@otherdomain.com"
|
|
)
|
|
self.assertTrue(
|
|
external_attendee,
|
|
"External organizer should be present in attendees",
|
|
)
|
|
# The external organizer should be in the attendees list
|
|
self.assertTrue(
|
|
external_attendee,
|
|
"External organizer should be present in attendees list",
|
|
)
|