Skip to content

Commit

Permalink
[FIX] calendar: allow internal users to download invitation.ics
Browse files Browse the repository at this point in the history
Access rights on ir.attachment depend on the record it is linked to.

steps to reproduce:
- log as admin
- create a calendar event and invite marc demo
- log as marc demo
- check discuss notifications and try to download "invite.ics"

before this commit:
- file can not be downloaded from the webclient (access error appear in logs)

after this commit:
- file can be downloaded from the webclient

opw-3754798

closes #160811

Signed-off-by: Arnaud Joset (arj) <arj@odoo.com>
  • Loading branch information
nda-odoo committed Apr 17, 2024
1 parent eb7fbfc commit 5b930b7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions addons/calendar/models/calendar_attendee.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,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(
Expand Down
20 changes: 19 additions & 1 deletion addons/calendar/tests/test_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from datetime import date, datetime, timedelta

from odoo import fields
from odoo.tests import Form, tagged
from odoo.tests import Form, tagged, new_test_user
from odoo.addons.base.tests.common import HttpCase, SavepointCaseWithUserDemo

import pytz
import re

Expand Down Expand Up @@ -331,6 +332,23 @@ def _test_one_mail_per_attendee(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_cache()


# 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
Expand Down

0 comments on commit 5b930b7

Please sign in to comment.