Skip to content

Commit af6f39d

Browse files
committed
[FIX] mass_mailing: ensure body_arch and body_html have the same fonts
The mail-safe font is applied to a style in <head> for emails. But the way it was applied, <div>s were forgotten. Since most of those are converted to tables when converting body_arch to body_html, it resulted in visible font differences between body_arch and body_html. Part-of: odoo#82233
1 parent a08c502 commit af6f39d

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

addons/mass_mailing/tests/test_mailing_ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ def test_01_mass_mailing_editor_tour(self):
2020
# for email client compatibility should be saved in body_html. This
2121
# ensures both fields have different values.
2222
self.assertEqual(mail.body_arch, '<p><br></p>')
23-
self.assertEqual(mail.body_html, '<p style="margin:0px 0 14px 0;box-sizing:border-box;font-family:Arial, sans-serif;"><br style="box-sizing:border-box;"></p>')
23+
self.assertEqual(mail.body_html, '<p style="margin:0px 0 14px 0;box-sizing:border-box;"><br style="box-sizing:border-box;"></p>')

addons/mass_mailing/views/assets.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414

1515
<template id="iframe_css_assets_readonly" groups="base.group_user">
1616
<link rel="stylesheet" type="text/scss" href="/mass_mailing/static/src/css/basic_theme_readonly.css"/>
17+
<t t-call="mass_mailing.mass_mailing_mail_style"/>
1718
</template>
1819

1920
<template id="mass_mailing_mail_style">
2021
<style>
2122
* {
2223
box-sizing: border-box !important;
2324
}
24-
* h1, h2, h3, h4, h5, h6, p, td, th {
25+
* h1, h2, h3, h4, h5, h6, p, td, th, div {
2526
font-family: Arial, sans-serif !important;
2627
}
2728
/* Remove space around the email design. */

addons/web_editor/static/src/js/backend/convert_inline.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ function classToStyle($editable, cssRules) {
289289
node.style[styleName] = '';
290290
}
291291
}
292+
// Ignore font-family (mail-safe font declared in <head>)
293+
if ('font-family' in css) {
294+
delete css['font-family'];
295+
}
292296

293297
// Do not apply css that would override inline styles (which are prioritary).
294298
let style = $target.attr('style') || '';

0 commit comments

Comments
 (0)