There was an issue when a mailing save failed: the edited body of the mailing
was lost.
Impacted versions:
- 15.0 and higher
Steps to reproduce:
1. Create a mailing "Start from scratch" and add some elements
2. Do not fill in the subject (or at least one required field)
3. Save (it should fail because of the empty required field)
Current behavior:
- The edited template is lost
Expected behavior:
- Keep the edited template even if the save failed
This commit fixes the problem by properly awaiting the promise _doAction so that
the field's value will be set correctly.
The testing tour `mass_mailing_editor_tour` is updated to check that the
body_arch is kept after a failed save.
This issue was introduced in 15.0 with:
95754eb6a4
Task-2856742
closes odoo/odoo#92186
X-original-commit: bc81178d541587f757d76932449d35ed426699aa
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
30 lines
1.4 KiB
Python
30 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
import odoo.tests
|
|
from odoo.addons.base.tests.common import HttpCaseWithUserDemo
|
|
|
|
|
|
@odoo.tests.tagged('-at_install', 'post_install')
|
|
class TestUi(HttpCaseWithUserDemo):
|
|
def setUp(self):
|
|
super().setUp()
|
|
self.user_demo.groups_id |= self.env.ref('mass_mailing.group_mass_mailing_user')
|
|
self.user_demo.groups_id |= self.env.ref('mail.group_mail_template_editor')
|
|
|
|
def test_01_mass_mailing_editor_tour(self):
|
|
self.start_tour("/web", 'mass_mailing_editor_tour', login="demo")
|
|
mail = self.env['mailing.mailing'].search([('subject', '=', 'Test')])[0]
|
|
# The tour created and saved an email. The edited version should be
|
|
# saved in body_arch, and its transpiled version (see convert_inline)
|
|
# for email client compatibility should be saved in body_html. This
|
|
# ensures both fields have different values (the mailing body should
|
|
# have been converted to a table in body_html).
|
|
self.assertIn('data-snippet="s_title"', mail.body_arch)
|
|
self.assertTrue(mail.body_arch.startswith('<div'))
|
|
self.assertIn('data-snippet="s_title"', mail.body_html)
|
|
self.assertTrue(mail.body_html.startswith('<table'))
|
|
|
|
def test_02_mass_mailing_snippets_menu_tabs(self):
|
|
self.start_tour("/web", 'mass_mailing_snippets_menu_tabs', login="demo")
|