diff --git a/addons/mail/models/ir_http.py b/addons/mail/models/ir_http.py index fe7c7e1d62c..c43321c03b7 100644 --- a/addons/mail/models/ir_http.py +++ b/addons/mail/models/ir_http.py @@ -13,7 +13,7 @@ class IrHttp(models.AbstractModel): result = super(IrHttp, self).session_info() if self.env.user._is_internal(): result['notification_type'] = user.notification_type - guest = self.env.context.get('guest') + guest = self.env['mail.guest']._get_guest_from_context() if not request.session.uid and guest: user_context = {'lang': guest.lang} mods = odoo.conf.server_wide_modules or [] diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index b7ed5668606..b956e26c534 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -197,10 +197,11 @@ class Message(models.Model): @api.depends_context('guest', 'uid') def _compute_is_current_user_or_guest_author(self): user = self.env.user + guest = self.env['mail.guest']._get_guest_from_context() for message in self: if not user._is_public() and (message.author_id and message.author_id == user.partner_id): message.is_current_user_or_guest_author = True - elif user._is_public() and (message.author_guest_id and message.author_guest_id == self.env.context.get('guest')): + elif message.author_guest_id and message.author_guest_id == guest: message.is_current_user_or_guest_author = True else: message.is_current_user_or_guest_author = False diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index b94df115261..f9d5f756a82 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -2023,8 +2023,9 @@ class MailThread(models.AbstractModel): self = self._fallback_lang() # Find the message's author - if self.env.user._is_public() and 'guest' in self.env.context: - author_guest_id = self.env.context['guest'].id + guest = self.env['mail.guest']._get_guest_from_context() + if self.env.user._is_public() and guest: + author_guest_id = guest.id author_id, email_from = False, False else: author_guest_id = False diff --git a/addons/mail/models/res_partner.py b/addons/mail/models/res_partner.py index 1817792ea2e..418731f5c5f 100644 --- a/addons/mail/models/res_partner.py +++ b/addons/mail/models/res_partner.py @@ -245,7 +245,7 @@ class Partner(models.Model): "id": main_user.id, "isInternalUser": not main_user.share, } if main_user else [('clear',)] - if 'guest' in self.env.context or not self.env.user._is_internal(): + if not self.env.user._is_internal(): data.pop('email', None) partners_format[partner] = data return partners_format