[FIX] calendar: Single char partner create traceback on calendar

Since 3a145216a6a6fb259c5afef6175669c8a65ba39f, partner_info value
was changed but not it's usage.

This commit also simplify the code for better understanding.

closes odoo/odoo#99422

Task-id: 2954397
X-original-commit: a667179e43ab00a8384b75923769782f1836c24b
Signed-off-by: Arnaud Joset <arj@odoo.com>
Signed-off-by: Damhaut Florian (flda) <flda@odoo.com>
This commit is contained in:
Florian Damhaut
2022-09-01 19:17:29 +02:00
committed by Arnaud Joset
parent 2179620aa7
commit 90bf897c28
+14 -19
View File
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from collections import defaultdict
from datetime import datetime
from odoo import api, fields, models
@@ -63,24 +62,20 @@ class Partner(models.Model):
"""
attendees_details = []
meetings = self.env['calendar.event'].browse(meeting_ids)
all_attendees = meetings.attendee_ids
attendees_by_partner = defaultdict(lambda: self.env['calendar.attendee'])
for attendee in all_attendees:
attendees_by_partner[attendee.partner_id.id] += attendee
for partner in self:
partner_info = partner.display_name
for attendee in attendees_by_partner[partner.id]:
attendee_is_organizer = self.env.user == attendee.event_id.user_id and attendee.partner_id == self.env.user.partner_id
attendees_details.append({
'id': partner_info[0],
'name': partner_info[1],
'status': attendee.state,
'event_id': attendee.event_id.id,
'attendee_id': attendee.id,
'is_alone': attendee.event_id.is_organizer_alone and attendee_is_organizer,
# attendees data is sorted according to this key in JS.
'is_organizer': 1 if attendee.partner_id == attendee.event_id.user_id.partner_id else 0,
})
for attendee in meetings.attendee_ids:
if attendee.partner_id not in self:
continue
attendee_is_organizer = self.env.user == attendee.event_id.user_id and attendee.partner_id == self.env.user.partner_id
attendees_details.append({
'id': attendee.partner_id.id,
'name': attendee.partner_id.display_name,
'status': attendee.state,
'event_id': attendee.event_id.id,
'attendee_id': attendee.id,
'is_alone': attendee.event_id.is_organizer_alone and attendee_is_organizer,
# attendees data is sorted according to this key in JS.
'is_organizer': 1 if attendee.partner_id == attendee.event_id.user_id.partner_id else 0,
})
return attendees_details
@api.model