[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) <arj@odoo.com>
This commit is contained in:
David Tran
2024-04-02 12:09:29 +00:00
parent ac6031f228
commit 804970a597
2 changed files with 59 additions and 0 deletions
@@ -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.
@@ -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 = {