From 804970a59753d6eb2ec6db5ba7b0b6f0c329bbc2 Mon Sep 17 00:00:00 2001 From: David Tran Date: Sat, 16 Mar 2024 12:05:21 +0700 Subject: [PATCH] [FIX] google_calendar: don't override existing videocall_location Remove 'videocall_location' when not sent by Google, otherwise the local videocall will be discarded. closes odoo/odoo#159111 X-original-commit: b56cd52bdd73c193d98fa334e80b363218cc13b9 Signed-off-by: Arnaud Joset (arj) --- addons/google_calendar/models/calendar.py | 3 + .../tests/test_sync_google2odoo.py | 56 +++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/addons/google_calendar/models/calendar.py b/addons/google_calendar/models/calendar.py index c9dbb214a39..5f7f053036f 100644 --- a/addons/google_calendar/models/calendar.py +++ b/addons/google_calendar/models/calendar.py @@ -149,6 +149,9 @@ class Meeting(models.Model): 'show_as': 'free' if google_event.is_available() else 'busy', 'guests_readonly': not bool(google_event.guestsCanModify) } + # Remove 'videocall_location' when not sent by Google, otherwise the local videocall will be discarded. + if not values.get('videocall_location'): + values.pop('videocall_location', False) if partner_commands: # Add partner_commands only if set from Google. The write method on calendar_events will # override attendee commands if the partner_ids command is set but empty. diff --git a/addons/google_calendar/tests/test_sync_google2odoo.py b/addons/google_calendar/tests/test_sync_google2odoo.py index 33fe0de68b4..72adec9faed 100644 --- a/addons/google_calendar/tests/test_sync_google2odoo.py +++ b/addons/google_calendar/tests/test_sync_google2odoo.py @@ -1256,6 +1256,62 @@ class TestSyncGoogle2Odoo(TestSyncGoogle): self.assertEqual(event.videocall_location, 'https://meet.google.com/odoo-random-test') self.assertGoogleAPINotCalled() + @patch_api + def test_event_with_local_videocall(self): + """This makes sure local video call is not discarded if google's meeting url is False""" + google_id = 'oj44nep1ldf8a3ll02uip0c9aa' + event = self.env['calendar.event'].create({ + 'name': 'coucou', + 'start': date(2020, 1, 6), + 'stop': date(2020, 1, 6), + 'google_id': google_id, + 'user_id': self.env.user.id, + 'need_sync': False, + 'partner_ids': [(6, 0, self.env.user.partner_id.ids)], + 'videocall_location': 'https://meet.google.com/odoo_local_videocall', + }) + values = { + 'id': google_id, + 'status': 'confirmed', + 'description': 'Event without meeting url', + 'organizer': {'email': 'odoocalendarref@gmail.com', 'self': True}, + 'summary': 'Event without meeting url', + 'visibility': 'public', + 'attendees': [{ + 'displayName': 'Mitchell Admin', + 'email': self.public_partner.email, + 'responseStatus': 'needsAction' + },], + 'reminders': {'useDefault': True}, + 'start': { + 'dateTime': '2020-01-13T16:55:00+01:00', + 'timeZone': 'Europe/Brussels' + }, + 'end': { + 'dateTime': '2020-01-13T19:55:00+01:00', + 'timeZone': 'Europe/Brussels' + }, + 'conferenceData': { + 'entryPoints': [{ + 'entryPointType': 'video', + 'uri': False, + 'label': 'no label' + }] + }, + 'updated': self.now, + } + # make sure local video call is not discarded + gevent = GoogleEvent([values]) + self.env['calendar.event']._sync_google2odoo(gevent) + self.assertEqual(event.videocall_location, 'https://meet.google.com/odoo_local_videocall') + + # now google has meet URL and make sure local video call is updated accordingly + values['conferenceData']['entryPoints'][0]['uri'] = 'https://meet.google.com/odoo-random-test' + gevent = GoogleEvent([values]) + self.env['calendar.event']._sync_google2odoo(gevent) + self.assertEqual(event.videocall_location, 'https://meet.google.com/odoo-random-test') + self.assertGoogleAPINotCalled() + @patch_api def test_event_with_availability(self): values = {