diff --git a/addons/mail/tests/common.py b/addons/mail/tests/common.py index eaa5d21bb26..dca9d428702 100644 --- a/addons/mail/tests/common.py +++ b/addons/mail/tests/common.py @@ -1072,7 +1072,7 @@ class MailCommon(common.TransactionCase, MailCase): return cls.user_portal @classmethod - def _create_records_for_batch(cls, model, count, additional_values=None, prefix=None): + def _create_records_for_batch(cls, model, count, additional_values=None, prefix=''): additional_values = additional_values or {} records = cls.env[model] partners = cls.env['res.partner'] diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index b32c39ed554..31532d97386 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -498,6 +498,8 @@ class MailComposer(models.TransientModel): messages = self.env['mail.message'] for res_id, post_values in post_values_all.items(): if ActiveModel._name == 'mail.thread': + post_values.pop('message_type') # forced to user_notification + post_values.pop('parent_id', False) # not supported in notify if self.model: post_values['model'] = self.model post_values['res_id'] = res_id diff --git a/addons/test_mail/tests/test_mail_thread_internals.py b/addons/test_mail/tests/test_mail_thread_internals.py index 56122681bac..36d254e3868 100644 --- a/addons/test_mail/tests/test_mail_thread_internals.py +++ b/addons/test_mail/tests/test_mail_thread_internals.py @@ -8,7 +8,7 @@ from werkzeug.urls import url_parse, url_decode from odoo import exceptions from odoo.addons.test_mail.models.test_mail_models import MailTestSimple from odoo.addons.test_mail.tests.common import TestMailCommon, TestRecipients -from odoo.tests.common import tagged, HttpCase, users +from odoo.tests.common import tagged, Form, HttpCase, users from odoo.tools import mute_logger @@ -473,6 +473,67 @@ class TestNoThread(TestMailCommon, TestRecipients): subject='Test Notify', ) + @users('employee') + def test_message_notify_composer(self): + """ Test comment mode on composer which triggers a notify when model + does not inherit from mail thread. """ + test_records, _test_partners = self._create_records_for_batch('mail.test.nothread', 2) + + test_reports = self.env['ir.actions.report'].sudo().create([ + { + 'name': 'Test Report on Mail Test Ticket', + 'model': test_records._name, + 'print_report_name': "'TestReport for %s' % object.name", + 'report_type': 'qweb-pdf', + 'report_name': 'test_mail.mail_test_ticket_test_template', + }, { + 'name': 'Test Report 2 on Mail Test Ticket', + 'model': test_records._name, + 'print_report_name': "'TestReport2 for %s' % object.name", + 'report_type': 'qweb-pdf', + 'report_name': 'test_mail.mail_test_ticket_test_template_2', + } + ]) + test_template = self.env['mail.template'].create({ + 'auto_delete': True, + 'body_html': '
TemplateBody