[FIX] calendar: set attendees on quickcreate

When creating an event through the quickcreate, the user creating the
event was not set as attendee.

closes odoo/odoo#58631

Taskid: 2334943
X-original-commit: 07d799a5f676ed68fd2ffd9cd9bac3269f947ad1
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
Kevin Baptiste
2020-09-28 10:46:17 +00:00
parent 75c2640ce5
commit 194850bc06
5 changed files with 14 additions and 10 deletions
+8 -6
View File
@@ -475,11 +475,12 @@ class Meeting(models.Model):
added_partner_ids += [command[1]] if command[1] not in self.partner_ids.ids else []
# commands 0 and 1 not supported
attendees_to_unlink = self.env['calendar.attendee'].search([
('event_id', 'in', self.ids),
('partner_id', 'in', removed_partner_ids),
])
attendee_commands += [[2, attendee.id] for attendee in attendees_to_unlink] # Removes and delete
if removed_partner_ids:
attendees_to_unlink = self.env['calendar.attendee'].search([
('event_id', 'in', self.ids),
('partner_id', 'in', removed_partner_ids),
])
attendee_commands += [[2, attendee.id] for attendee in attendees_to_unlink] # Removes and delete
attendee_commands += [
[0, 0, dict(partner_id=partner_id)]
@@ -699,8 +700,9 @@ class Meeting(models.Model):
activity_vals['user_id'] = user_id
values['activity_ids'] = [(0, 0, activity_vals)]
self_partner_id = [(4, self.env.user.partner_id.id)]
vals_list = [
dict(vals, attendee_ids=self._attendees_values(vals['partner_ids'])) if 'partner_ids' in vals else vals
dict(vals, attendee_ids=self._attendees_values(vals.get('partner_ids', self_partner_id)))
for vals in vals_list
]
recurrence_fields = self._get_recurrent_fields()
+2 -2
View File
@@ -11,12 +11,12 @@ class TestEventNotifications(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.event = cls.env['calendar.event'].create({
cls.user = new_test_user(cls.env, 'xav', email='em@il.com', notification_type='inbox')
cls.event = cls.env['calendar.event'].with_user(cls.user).create({
'name': "Doom's day",
'start': datetime(2019, 10, 25, 8, 0),
'stop': datetime(2019, 10, 27, 18, 0),
}).with_context(mail_notrack=True)
cls.user = new_test_user(cls.env, 'xav', email='em@il.com', notification_type='inbox')
cls.partner = cls.user.partner_id
def test_attendee_added(self):
+2 -1
View File
@@ -167,6 +167,7 @@ class Meeting(models.Model):
'method': "email" if alarm.alarm_type == "email" else "popup",
'minutes': alarm.duration_minutes
} for alarm in self.alarm_ids]
attendee_ids = self.attendee_ids.filtered(lambda a: a.partner_id != self.env.user.partner_id)
values = {
'id': self.google_id,
'start': start,
@@ -176,7 +177,7 @@ class Meeting(models.Model):
'location': self.location or '',
'guestsCanModify': True,
'organizer': {'email': self.user_id.email, 'self': self.user_id == self.env.user},
'attendees': [{'email': attendee.email, 'responseStatus': attendee.state} for attendee in self.attendee_ids],
'attendees': [{'email': attendee.email, 'responseStatus': attendee.state} for attendee in attendee_ids],
'extendedProperties': {
'shared': {
'%s_odoo_id' % self.env.cr.dbname: self.id,
+1
View File
@@ -894,6 +894,7 @@ class HolidaysRequest(models.Model):
'privacy': 'confidential',
'event_tz': holiday.user_id.tz,
'activity_ids': [(5, 0, 0)],
'partner_ids': [],
}
# Add the partner_id (if exist) as an attendee
if holiday.user_id and holiday.user_id.partner_id:
@@ -313,7 +313,7 @@ class TestCompanyLeave(SavepointCase):
})
company_leave._compute_date_from_to()
count = 865
count = 863
with self.assertQueryCount(__system__=count, admin=count):
# Original query count: 1987
# Without tracking/activity context keys: 5154