[REF] mass_mailing: clean up assets views

This commit handles 2 things:

- Clarifies why some inline style has to remain inline instead of being moved
to a separate file.

- Moves an inline modification to field_html for testing purpose to
a dedicated file.

This has been done to improve consistency in asset bundles declarations
by reducing them to the simplest possible templates.

Part of task: 2352566

Co-authored-by: Julien Mougenot <jum@odoo.com>
Co-authored-by: Simon Genin <ges@odoo.com>
This commit is contained in:
Julien Mougenot
2021-03-31 13:57:17 +02:00
co-authored by Simon Genin
parent 043079d4dd
commit a3373db4b8
4 changed files with 24 additions and 10 deletions
+4 -1
View File
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo><data noupdate="1">
<!-- Reference: https://litmus.com/community/learning/24-how-to-code-a-responsive-email-from-scratch -->
<!--
Reference: https://litmus.com/community/learning/24-how-to-code-a-responsive-email-from-scratch
https://www.campaignmonitor.com/css/link-element/link-in-head/
-->
<template id="mass_mailing_mail_layout">
&lt;!DOCTYPE html&gt;
<html xmlns="http://www.w3.org/1999/xhtml">
@@ -0,0 +1,4 @@
/** @odoo-module alias=mass_mailing.FieldHtml.test */
import MassMailingFieldHtml from "mass_mailing.FieldHtml";
MassMailingFieldHtml.include({ jsLibs: [] });
@@ -20,7 +20,13 @@ class TestMassMailValues(MassMailCommon):
@users('user_marketing')
def test_mailing_body_responsive(self):
""" Testing mail mailing responsive mail body """
""" Testing mail mailing responsive mail body
Reference: https://litmus.com/community/learning/24-how-to-code-a-responsive-email-from-scratch
https://www.campaignmonitor.com/css/link-element/link-in-head/
This template is meant to put inline CSS into an email's head
"""
recipient = self.env['res.partner'].create({
'name': 'Mass Mail Partner',
'email': 'Customer <test.customer@example.com>',
@@ -48,6 +54,7 @@ class TestMassMailValues(MassMailCommon):
self.assertIn('<!DOCTYPE html>', body_html)
self.assertIn('<head>', body_html)
self.assertIn('viewport', body_html)
# This is important: we need inline css, and not <link/>
self.assertIn('@media', body_html)
self.assertIn('I am Responsive body', body_html)
+8 -8
View File
@@ -17,7 +17,6 @@
<template id="assets_mail_themes">
<link rel="stylesheet" type="text/scss" href="/mass_mailing/static/src/scss/themes/theme_basic.scss"/>
<link rel="stylesheet" type="text/scss" href="/mass_mailing/static/src/scss/themes/theme_default.scss"/>
<t t-call="mass_mailing.mass_mailing_mail_style"/>
</template>
<template id="assets_mail_themes_edition"> <!-- maybe to remove and convert into a field dumy with attr invisible if the template is not selected -->
@@ -29,6 +28,7 @@
<template id="iframe_css_assets_edit" groups="base.group_user">
<t t-call-assets="mass_mailing.assets_mail_themes" t-js="false"/>
<t t-call="mass_mailing.mass_mailing_mail_style"/>
<t t-call-assets="mass_mailing.assets_mail_themes_edition" t-js="false"/>
</template>
@@ -44,19 +44,19 @@
<template id="qunit_suite" inherit_id="web.qunit_suite_tests">
<xpath expr="." position="inside">
<script type="text/javascript">
odoo.define('mass_mailing.FieldHtml.test', function (require) {
'use strict';
var MassMailingFieldHtml = require('mass_mailing.FieldHtml');
MassMailingFieldHtml.include({jsLibs: []});
});
</script>
<script type="text/javascript" src="/mass_mailing/static/tests/field_html_test.js"/>
<script type="text/javascript" src="/mass_mailing/static/src/js/mass_mailing_snippets.js"/>
<script type="text/javascript" src="/mass_mailing/static/tests/mass_mailing_html_tests.js"/>
</xpath>
</template>
<template id="mass_mailing_mail_style">
<!--
Reference: https://litmus.com/community/learning/24-how-to-code-a-responsive-email-from-scratch
https://www.campaignmonitor.com/css/link-element/link-in-head/
This template is meant to put inline CSS into an email's head
-->
<style>
@media screen and (max-width: 768px) {
.o_mail_col_mv {