[FIX] calendar: expected singleton error with _find_attendee

Issue
-----

Opening the calendar view may lead to an expected singleton error
because _find_attendee my return a recordset with a len > 1

Solution
--------
Return the first element of the filtered list to match the behavior
described in the doc string

closes odoo/odoo#75277

X-original-commit: b3a17e8c233f0b31c61609fefbc24241c3d12ae4
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Arnaud Joset <arj-odoo@users.noreply.github.com>
This commit is contained in:
Thibault Francois
2021-08-24 06:49:03 +00:00
committed by Arnaud Joset
parent 2cbb691a84
commit 6ec80fe459
+3 -3
View File
@@ -788,7 +788,7 @@ class Meeting(models.Model):
my_attendee = self.attendee_ids.filtered(lambda att: att.partner_id == self.env.user.partner_id)
if my_attendee:
return my_attendee
return my_attendee[:1]
event_checked_attendees = self.env['calendar.contacts'].search([
('user_id', '=', self.env.user.id),
@@ -796,10 +796,10 @@ class Meeting(models.Model):
('partner_checked', '=', True)
]).mapped('partner_id')
if self.partner_id in event_checked_attendees and self.partner_id in self.attendee_ids.partner_id:
return self.attendee_ids.filtered(lambda attendee: attendee.partner_id == self.partner_id)
return self.attendee_ids.filtered(lambda attendee: attendee.partner_id == self.partner_id)[:1]
attendee = self.attendee_ids.filtered(lambda att: att.partner_id in event_checked_attendees and att.state != "needsAction")
return attendee
return attendee[:1]
def _get_start_date(self):
"""Return the event starting date in the event's timezone.