[FIX] google_calendar: sync events without an attendee's state
Before this commit: if an event's attendee didn't have a state, it couldn't get synced with Google. The solution is first to set a default value for it. opw-2915661 closes odoo/odoo#102865 X-original-commit: 89b53744c668183913b8a188730bd350fe778807 Signed-off-by: Arnaud Joset <arj@odoo.com> Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
This commit is contained in:
@@ -224,7 +224,10 @@ class Meeting(models.Model):
|
||||
if self.user_id and self.user_id != self.env.user and bool(self.user_id.sudo().google_calendar_token):
|
||||
# We avoid updating the other attendee status if we are not the organizer
|
||||
attendees = self.attendee_ids.filtered(lambda att: att.partner_id == self.env.user.partner_id)
|
||||
attendee_values = [{'email': attendee.partner_id.email_normalized, 'responseStatus': attendee.state} for attendee in attendees if attendee.partner_id.email_normalized]
|
||||
attendee_values = [{
|
||||
'email': attendee.partner_id.email_normalized,
|
||||
'responseStatus': attendee.state or 'needsAction',
|
||||
} for attendee in attendees if attendee.partner_id.email_normalized]
|
||||
# We sort the attendees to avoid undeterministic test fails. It's not mandatory for Google.
|
||||
attendee_values.sort(key=lambda k: k['email'])
|
||||
values = {
|
||||
|
||||
@@ -134,6 +134,40 @@ class TestSyncOdoo2Google(TestSyncGoogle):
|
||||
values = event._google_values()
|
||||
self.assertFalse('%s_owner_id' % self.env.cr.dbname in values.get('extendedProperties', {}).get('shared', {}))
|
||||
|
||||
@patch_api
|
||||
def test_event_without_attendee_state(self):
|
||||
partner_1 = self.env['res.partner'].create({'name': 'Jean-Luc', 'email': 'jean-luc@opoo.com'})
|
||||
partner_2 = self.env['res.partner'].create({'name': 'Phineas', 'email': 'phineas@opoo.com'})
|
||||
partner_3 = self.env['res.partner'].create({'name': 'Ferb'})
|
||||
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_1.id), (4, partner_2.id), (4, partner_3.id)],
|
||||
'privacy': 'private',
|
||||
'need_sync': False,
|
||||
})
|
||||
attendee_2 = event.attendee_ids.filtered(lambda a: a.partner_id.id == partner_2.id)
|
||||
attendee_2.write({
|
||||
'state': False,
|
||||
})
|
||||
event._sync_odoo2google(self.google_service)
|
||||
self.assertGoogleEventInserted({
|
||||
'id': False,
|
||||
'start': {'dateTime': '2020-01-15T08:00:00+00:00'},
|
||||
'end': {'dateTime': '2020-01-15T18:00:00+00:00'},
|
||||
'summary': 'Event',
|
||||
'description': '',
|
||||
'location': '',
|
||||
'visibility': 'private',
|
||||
'guestsCanModify': True,
|
||||
'reminders': {'useDefault': False, 'overrides': []},
|
||||
'organizer': {'email': 'odoobot@example.com', 'self': True},
|
||||
'attendees': [{'email': 'jean-luc@opoo.com', 'responseStatus': 'needsAction'},
|
||||
{'email': 'phineas@opoo.com', 'responseStatus': 'needsAction'}],
|
||||
'extendedProperties': {'shared': {'%s_odoo_id' % self.env.cr.dbname: event.id}}
|
||||
})
|
||||
|
||||
@patch_api
|
||||
def test_event_allday_creation(self):
|
||||
event = self.env['calendar.event'].create({
|
||||
|
||||
Reference in New Issue
Block a user