From 5e9918f8459c113f1fbf5e59c167fc79a0767f6a Mon Sep 17 00:00:00 2001 From: "kdeb@odoo.com" Date: Fri, 15 Dec 2023 17:46:37 +0000 Subject: [PATCH] [FIX] google_calendar: prevent google meet links when location is set Issue When a location is set on an event, the google meet link is also generated, leading to confusion about the meeting format. Steps to reproduce - Create an event with a location - Sync the Calendar with Google. - Observe that a Google Meet link is sent with the email. Solution check if the loacation is set before generating a google meet link. opw-3589379 closes odoo/odoo#149654 X-original-commit: 6aabe1b30598a8a616db01ae46dffece8f3f876c Signed-off-by: Leonardo Pavan Rocha Signed-off-by: Kawtar Drissi El Bouzaidi (kdeb) --- addons/google_calendar/models/calendar.py | 2 +- addons/google_calendar/tests/test_sync_common.py | 5 +++++ .../google_calendar/tests/test_sync_odoo2google.py | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/addons/google_calendar/models/calendar.py b/addons/google_calendar/models/calendar.py index a835aa06ca2..c9dbb214a39 100644 --- a/addons/google_calendar/models/calendar.py +++ b/addons/google_calendar/models/calendar.py @@ -313,7 +313,7 @@ class Meeting(models.Model): 'useDefault': False, } } - if not self.google_id and not self.videocall_location: + if not self.google_id and not self.videocall_location and not self.location: values['conferenceData'] = {'createRequest': {'requestId': uuid4().hex}} if self.privacy: values['visibility'] = self.privacy diff --git a/addons/google_calendar/tests/test_sync_common.py b/addons/google_calendar/tests/test_sync_common.py index b5fd0354a40..8ebf95309a9 100644 --- a/addons/google_calendar/tests/test_sync_common.py +++ b/addons/google_calendar/tests/test_sync_common.py @@ -76,3 +76,8 @@ class TestSyncGoogle(HttpCase): while funcs: func = funcs.popleft() func() + + def assertGoogleEventHasNoConferenceData(self): + GoogleSync._google_insert.assert_called_once() + args, _ = GoogleSync._google_insert.call_args + self.assertFalse(args[1].get('conferenceData', False)) diff --git a/addons/google_calendar/tests/test_sync_odoo2google.py b/addons/google_calendar/tests/test_sync_odoo2google.py index 6dcefb737d6..9b4e21cc52e 100644 --- a/addons/google_calendar/tests/test_sync_odoo2google.py +++ b/addons/google_calendar/tests/test_sync_odoo2google.py @@ -764,3 +764,17 @@ class TestSyncOdoo2Google(TestSyncGoogle): self.assertFalse(record.active, "Event must be archived in Odoo after unlinking it") self.assertTrue(record.need_sync, "Sync variable must be true for updating event in Google when sync re-activates") self.assertGoogleEventNotDeleted() + + @patch_api + def test_videocall_location_on_location_set(self): + partner = self.env['res.partner'].create({'name': 'Jean-Luc', 'email': 'jean-luc@opoo.com'}) + event = self.env['calendar.event'].create({ + 'name': "Event", + 'start': datetime(2020, 1, 15, 8, 0), + 'stop': datetime(2020, 1, 15, 18, 0), + 'partner_ids': [(4, partner.id)], + 'need_sync': False, + 'location' : 'Event Location' + }) + event._sync_odoo2google(self.google_service) + self.assertGoogleEventHasNoConferenceData()