From acfb07e79c0ede07d6f52df1f51bb4582c583226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 6 Mar 2023 09:56:24 +0000 Subject: [PATCH] [FIX] mail: effectively allow to post when notified on unreachable documents When being notified on a document they cannot read users should be able to post, as indicated in message ACLs. However some data preparation prevents from doing it as ACLs are raised on document level. In this commit we sudo the call to display_name to populate record_name when not given. Indeed access is checked at message level so no need to crash in this specific use case. Task-3213982 (Mail: fix 'multi-company' post support) X-original-commit: odoo/odoo@2d73c6113615afe62fe8317f0e9a70ed037c0143 Part-of: odoo/odoo#114511 --- addons/mail/models/mail_thread.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 5e333cc56fb..f3f5401bc92 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -2011,7 +2011,9 @@ class MailThread(models.AbstractModel): if 'email_add_signature' not in msg_values: msg_values['email_add_signature'] = True if not msg_values.get('record_name'): - msg_values['record_name'] = self.display_name + # use sudo as record access is not always granted (notably when replying + # a notification) -> final check is done at message creation level + msg_values['record_name'] = self.sudo().display_name msg_values.update({ # author 'author_id': author_id,