diff --git a/addons/mail/models/mail_activity.py b/addons/mail/models/mail_activity.py index 63a86c7bbdb..5e5741cf6e6 100644 --- a/addons/mail/models/mail_activity.py +++ b/addons/mail/models/mail_activity.py @@ -557,7 +557,7 @@ class MailActivity(models.Model): 'res_model': activity_message._name, }) activity_message.attachment_ids = message_attachments - messages |= activity_message + messages += activity_message next_activities = self.env['mail.activity'].create(next_activities_values) self.unlink() # will unlink activity, dont access `self` after that diff --git a/addons/mail/models/mail_activity_mixin.py b/addons/mail/models/mail_activity_mixin.py index 9528886ace5..d29c482b7fc 100644 --- a/addons/mail/models/mail_activity_mixin.py +++ b/addons/mail/models/mail_activity_mixin.py @@ -443,7 +443,7 @@ class MailActivityMixin(models.AbstractModel): for record in self: render_context['object'] = record note = self.env['ir.qweb']._render(view_ref, render_context, minimal_qcontext=True, raise_if_not_found=False) - activities |= record.activity_schedule(act_type_xmlid=act_type_xmlid, date_deadline=date_deadline, summary=summary, note=note, **act_values) + activities += record.activity_schedule(act_type_xmlid=act_type_xmlid, date_deadline=date_deadline, summary=summary, note=note, **act_values) return activities def activity_reschedule(self, act_type_xmlids, user_id=None, date_deadline=None, new_user_id=None): diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index a8bb8e81e6c..617b22308d8 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -997,7 +997,7 @@ class Message(models.Model): except AccessError: continue else: - messages |= message + messages += message messages_per_partner = defaultdict(lambda: self.env['mail.message']) for message in messages: if not self.env.user._is_public(): diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index efdeae20be8..43984c8b2df 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -2045,7 +2045,7 @@ class MailThread(models.AbstractModel): def message_post_with_view(self, views_or_xmlid, **kwargs): """ Helper method to send a mail / post a message using a view_id """ - self._message_compose_with_view(views_or_xmlid, **kwargs) + return self._message_compose_with_view(views_or_xmlid, **kwargs) def message_post_with_template(self, template_id, email_layout_xmlid=None, auto_commit=False, **kwargs): """ Helper method to send a mail with a template @@ -2518,7 +2518,7 @@ class MailThread(models.AbstractModel): 'is_read': True, # discard Inbox notification 'notification_status': 'ready', } for recipient_id in tocreate_recipient_ids] - emails |= new_email + emails += new_email if notif_create_values: SafeNotification.create(notif_create_values) diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 4229b0f0c0c..2be52e4ac1d 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -240,7 +240,13 @@ class MailComposer(models.TransientModel): def _action_send_mail(self, auto_commit=False): """ Process the wizard content and proceed with sending the related - email(s), rendering any template patterns on the fly if needed. """ + email(s), rendering any template patterns on the fly if needed. + + :return tuple: ( + result_mails_su: in mass mode, sent emails (as sudo), + result_messages: in comment mode, posted messages + ) + """ # Several custom layouts make use of the model description at rendering, e.g. in the # 'View ' button. Some models are used for different business concepts, such as # 'purchase.order' which is used for a RFQ and and PO. To avoid confusion, we must use a @@ -248,6 +254,7 @@ class MailComposer(models.TransientModel): # Therefore, we can set the description in the context from the beginning to avoid falling # back on the regular display_name retrieved in ``_notify_by_email_prepare_rendering_context()``. model_description = self._context.get('model_description') + result_mails_su, result_messages = self.env['mail.mail'].sudo(), self.env['mail.message'] for wizard in self: # Duplicate attachments linked to the email.template. @@ -299,7 +306,7 @@ class MailComposer(models.TransientModel): all_mail_values = wizard.get_mail_values(res_ids) for res_id, mail_values in all_mail_values.items(): if wizard.composition_mode == 'mass_mail': - batch_mails_sudo |= self.env['mail.mail'].sudo().create(mail_values) + batch_mails_sudo += self.env['mail.mail'].sudo().create(mail_values) else: post_params = dict( message_type=wizard.message_type, @@ -317,11 +324,14 @@ class MailComposer(models.TransientModel): # if message_notify returns an empty record set, no recipients where found. raise UserError(_("No recipient found.")) else: - ActiveModel.browse(res_id).message_post(**post_params) + result_messages += ActiveModel.browse(res_id).message_post(**post_params) + result_mails_su += batch_mails_sudo if wizard.composition_mode == 'mass_mail': batch_mails_sudo.send(auto_commit=auto_commit) + return result_mails_su, result_messages + def action_save_as_template(self): """ hit save as template button: current form value will be a new template attached to the current document. """