diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 662edbeac5d..77018787e82 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -1893,7 +1893,7 @@ class MailThread(models.AbstractModel): if not partner_ids: _logger.warning('Message notify called without recipient_ids, skipping') - return self.env['mail_message'] + return self.env['mail.message'] if not (model and res_id): # both value should be set or none should be set (record) model = False diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index cd0da38fbb0..a968bb80cd9 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -8,6 +8,7 @@ import re from odoo import _, api, fields, models, SUPERUSER_ID, tools from odoo.tools.safe_eval import safe_eval +from odoo.exceptions import UserError # main mako-like expression pattern @@ -283,7 +284,9 @@ class MailComposer(models.TransientModel): if wizard.model: post_params['model'] = wizard.model post_params['res_id'] = res_id - ActiveModel.message_notify(**post_params) + if not ActiveModel.message_notify(**post_params): + # 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)