Files
odoo_source/addons/base_automation/tests/test_mail_composer.py
T
Jinal PatelandThibault Delavallee 223b51c462 [FIX] mail: fix ACLs issue with mail composer in new mode
As create_uid has no value on mail.compose.message model when being in onchange
or new mode, 'Mail Compose Message Rule' record rule may crash. In this
commit we fix that issue by adding a value for create_uid. An unit test is
added to ensure it effectively fixes the use case.

Steps to reproduce this warning:
 1. Create automated action for the 'mail.compose.message' model
 2. Try to open 'Email compose Wizard'

Warning:

"Due to security restrictions, you are not allowed to modify 'Email composition
wizard' (mail.compose.message) records.

Records: mail.compose.message,NewId_0x7f8e99762310 (id=NewId_0x7f8e99762310)
User: USERNAME (id=2)

This restriction is due to the following rules:

Contact your administrator to request access if necessary."

Task-2641572
opw-2628005
PR odoo#76159
Closes#75369

X-original-commit: 26d64c0b84b76bb9164a8895bcc21b66754478ae
Part-of: odoo/odoo#77005
Co-authored-by: Thibault Delavallee <tde@odoo.com>
2021-09-22 19:25:55 +00:00

40 lines
1.5 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests.common import tagged, HttpCase
@tagged('-at_install', 'post_install', 'mail_composer')
class TestMailFullComposer(HttpCase):
def test_full_composer_tour(self):
self.env['mail.template'].create({
'name': 'Test template', # name hardcoded for test
'partner_to': '${object.id}',
'lang': '${object.lang}',
'auto_delete': True,
'model_id': self.ref('base.model_res_partner'),
})
test_user = self.env['res.users'].create({
'email': 'testuser@testuser.com',
'groups_id': [
(6, 0, [self.ref('base.group_user'), self.ref('base.group_partner_manager')]),
],
'name': 'Test User',
'login': 'testuser',
'password': 'testuser',
})
automated_action = self.env['base.automation'].create({
'name': 'Test',
'active': True,
'trigger': 'on_change',
'on_change_field_ids': (4, self.ref('mail.field_mail_compose_message__template_id'),),
'state': 'code',
'model_id': self.env.ref('mail.model_mail_compose_message').id,
})
self.start_tour("/web#id=%d&model=res.partner" % test_user.partner_id, 'mail/static/tests/tours/mail_full_composer_test_tour.js', login='testuser')
automated_action.unlink()