summaryrefslogtreecommitdiff
path: root/addons/test_mail/tests/test_mail_mail.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2019-10-24 09:05:16 +0000
committerThibault Delavallée <tde@odoo.com>2019-11-29 13:35:14 +0000
commit69ccabb212d83bfee60c7dade36ca4b06f9f2f12 (patch)
tree18049ec2a94b7da7d0890bae10c8d35c2d01d427 /addons/test_mail/tests/test_mail_mail.py
parent1838191eece59051805862ed6ce914bf5e5d1efb (diff)
[FIX] mail: restrict access to mail.mail model
From now on mail.mail is considered as a technical model. Indeed people should not really manually craft mails by hand. Instead various functional flows should either send mails, either craft mails based on some user input. We therefore make mail restricted to admin users. Flows creating mail.mail are updated to use sudo, and ensure it was done in a context that makes sense to delegate this power to the user. Task ID 1853147 PR #32243
Diffstat (limited to 'addons/test_mail/tests/test_mail_mail.py')
-rw-r--r--addons/test_mail/tests/test_mail_mail.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/addons/test_mail/tests/test_mail_mail.py b/addons/test_mail/tests/test_mail_mail.py
index 7fb29598e6f..7e6b0f98ba2 100644
--- a/addons/test_mail/tests/test_mail_mail.py
+++ b/addons/test_mail/tests/test_mail_mail.py
@@ -15,8 +15,7 @@ class TestMailMail(TestMailCommon):
@mute_logger('odoo.addons.mail.models.mail_mail')
def test_mail_message_notify_from_mail_mail(self):
# Due ot post-commit hooks, store send emails in every step
- # self.email_to_list = []
- mail = self.env['mail.mail'].create({
+ mail = self.env['mail.mail'].sudo().create({
'body_html': '<p>Test</p>',
'email_to': 'test@example.com',
'partner_ids': [(4, self.user_employee.partner_id.id)]
@@ -28,7 +27,7 @@ class TestMailMail(TestMailCommon):
@mute_logger('odoo.addons.mail.models.mail_mail')
def test_mail_message_values_unicode(self):
- mail = self.env['mail.mail'].create({
+ mail = self.env['mail.mail'].sudo().create({
'body_html': '<p>Test</p>',
'email_to': 'test.😊@example.com',
'partner_ids': [(4, self.user_employee.partner_id.id)]
@@ -45,7 +44,7 @@ class TestMailMailRace(common.TransactionCase):
'name': 'Ernest Partner',
})
# we need to simulate a mail sent by the cron task, first create mail, message and notification by hand
- mail = self.env['mail.mail'].create({
+ mail = self.env['mail.mail'].sudo().create({
'body_html': '<p>Test</p>',
'notification': True,
'state': 'outgoing',