Skip to content
Snippets Groups Projects
Commit 95754eb6 authored by Antoine Guenet's avatar Antoine Guenet
Browse files

[FIX] mass_mailing: save transpiled html without affecting body_arch

Since the introduction of Odoo Editor, `field_html`'s `_getValue` uses
`wysiwyg.getValue`. This conflicts with the mechanism of `mass_mailing`
which modifies the html of the editable area in place to save an
"e-mailable" version on the `body_html` field, then relies on
`_getValue` to reset the original html (`body_arch`).
This ensures the field has a value before modifying the html in place,
so we can manually restore it instead of relying on a side effect of the
old behavior of `_getValue`.

Part-of: odoo/odoo#75901
parent 3fa36762
No related branches found
No related tags found
No related merge requests found
......@@ -65,6 +65,7 @@ var MassMailingFieldHtml = FieldHtml.extend({
}
return this.wysiwyg.saveModifiedImages(this.$content).then(function () {
self._isDirty = self.wysiwyg.isDirty();
self._doAction();
convertInline.attachmentThumbnailToLinkImg($editable);
convertInline.fontToImg($editable);
......@@ -84,6 +85,7 @@ var MassMailingFieldHtml = FieldHtml.extend({
changes: _.object([fieldName], [self._unWrap($editable.html())])
});
$editable.html(self.value);
if (self._isDirty && self.mode === 'edit') {
return self._doAction();
}
......
odoo.define('mass_mailing.mass_mailing_editor_tour', function (require) {
"use strict";
var tour = require('web_tour.tour');
tour.register('mass_mailing_editor_tour', {
url: '/web',
test: true,
}, [tour.stepUtils.showAppsMenuItem(), {
trigger: '.o_app[data-menu-xmlid="mass_mailing.mass_mailing_menu_root"]',
}, {
trigger: 'button.o_list_button_add',
}, {
trigger: 'input[name="subject"]',
run: 'text Test',
}, {
trigger: 'div[name="contact_list_ids"] .o_input_dropdown > input[type="text"]',
}, {
trigger: 'li.ui-menu-item',
}, {
trigger: 'iframe #default',
run: () => $('iframe').contents().find('o_editable').html('<p><br/></p>'),
}, {
trigger: 'button.o_form_button_save',
}, {
trigger: 'iframe.o_readonly',
}]);
});
......@@ -7,3 +7,4 @@ from . import test_mailing_internals
from . import test_mailing_list
from . import test_mailing_controllers
from . import test_mailing_mailing_schedule_date
from . import test_mailing_ui
# -*- 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.
self.assertEqual(mail.body_arch, '<p><br></p>')
self.assertEqual(mail.body_html, '<p style="margin:0px 0 1rem 0;"><br></p>')
......@@ -24,7 +24,7 @@ function getMatchedCSSRules(a) {
try {
rules = sheets[i].rules || sheets[i].cssRules;
} catch (e) {
console.warn("Can't read the css rules of: " + sheets[i].href, e);
console.log("Can't read the css rules of: " + sheets[i].href, e);
continue;
}
if (rules) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment