diff --git a/addons/calendar/models/calendar_attendee.py b/addons/calendar/models/calendar_attendee.py index f5fc83591dcab..8f2babee6d6aa 100644 --- a/addons/calendar/models/calendar_attendee.py +++ b/addons/calendar/models/calendar_attendee.py @@ -118,6 +118,8 @@ def _send_mail_to_attendees(self, mail_template, force_send=False): attachment_values += [ (0, 0, {'name': 'invitation.ics', 'mimetype': 'text/calendar', + 'res_id': event_id, + 'res_model': 'calendar.event', 'datas': base64.b64encode(ics_file)}) ] body = mail_template._render_field( diff --git a/addons/calendar/tests/test_calendar.py b/addons/calendar/tests/test_calendar.py index d3351215f0445..e64b0fb823eff 100644 --- a/addons/calendar/tests/test_calendar.py +++ b/addons/calendar/tests/test_calendar.py @@ -6,7 +6,7 @@ from odoo import fields, Command from odoo.addons.base.tests.common import HttpCaseWithUserDemo -from odoo.tests import Form, HttpCase, tagged +from odoo.tests import Form, tagged, new_test_user from odoo.addons.base.tests.common import SavepointCaseWithUserDemo import pytz import re @@ -351,6 +351,23 @@ def _test_emails_has_attachment(self, partners): # no more email should be sent _test_one_mail_per_attendee(self, partners) + def test_event_creation_internal_user_invitation_ics(self): + """ Check that internal user can read invitation.ics attachment """ + internal_user = new_test_user(self.env, login='internal_user', groups='base.group_user') + + partner = internal_user.partner_id + self.event_tech_presentation.write({ + 'partner_ids': [(4, partner.id)], + }) + msg = self.env['mail.message'].search([ + ('notified_partner_ids', 'in', partner.id), + ]) + msg.invalidate_recordset() + + + # internal user can read the attachment without errors + self.assertEqual(msg.with_user(internal_user).attachment_ids.name, 'invitation.ics') + def test_event_creation_sudo_other_company(self): """ Check Access right issue when create event with sudo