From 19b0c0cd53351a0dec1d07027e17df1afbdf37a5 Mon Sep 17 00:00:00 2001 From: Khoi Vo Date: Mon, 7 Oct 2024 15:51:39 +0700 Subject: [PATCH] [18.0][MIG] mail_inline_css: Migrate to 18.0 --- mail_inline_css/README.rst | 17 ++-- mail_inline_css/__manifest__.py | 6 +- mail_inline_css/demo/demo_mail_template.xml | 96 ++++++++++++++++++- mail_inline_css/demo/demo_template.xml | 92 ------------------ mail_inline_css/models/mail_template.py | 14 +-- mail_inline_css/readme/CONTRIBUTORS.md | 1 + mail_inline_css/readme/CREDITS.md | 2 +- mail_inline_css/static/description/index.html | 3 +- .../tests/test_mail_inline_styles.py | 4 +- 9 files changed, 116 insertions(+), 119 deletions(-) delete mode 100644 mail_inline_css/demo/demo_template.xml diff --git a/mail_inline_css/README.rst b/mail_inline_css/README.rst index ddb3647e..1564d4ab 100644 --- a/mail_inline_css/README.rst +++ b/mail_inline_css/README.rst @@ -60,24 +60,25 @@ Authors Contributors ------------ -- David BEAL +- David BEAL -- Akim Juillerat +- Akim Juillerat -- Simone Orsi +- Simone Orsi -- Patrick Tombez +- Patrick Tombez -- Phuc Tran Thanh +- Phuc Tran Thanh -- `Trobz `__: +- `Trobz `__: - - Son Ho + - Son Ho + - Khoi Vo Other credits ------------- -The migration of this module from 15.0 to 16.0 was financially supported +The migration of this module from 16.0 to 18.0 was financially supported by Camptocamp Maintainers diff --git a/mail_inline_css/__manifest__.py b/mail_inline_css/__manifest__.py index 1f94d47d..220e822e 100644 --- a/mail_inline_css/__manifest__.py +++ b/mail_inline_css/__manifest__.py @@ -5,13 +5,13 @@ { "name": "Mail Inline CSS", "summary": "Convert style tags in inline style in your mails", - "version": "16.0.0.1.0", + "version": "18.0.1.0.0", "author": "Akretion, camptocamp, Odoo Community Association (OCA)", "website": "https://github.com/OCA/social", "license": "AGPL-3", "category": "Tools", "installable": True, "external_dependencies": {"python": ["premailer"]}, - "depends": ["email_template_qweb"], - "demo": ["demo/demo_template.xml", "demo/demo_mail_template.xml"], + "depends": ["mail"], + "demo": ["demo/demo_mail_template.xml"], } diff --git a/mail_inline_css/demo/demo_mail_template.xml b/mail_inline_css/demo/demo_mail_template.xml index 57211f97..a26086e5 100644 --- a/mail_inline_css/demo/demo_mail_template.xml +++ b/mail_inline_css/demo/demo_mail_template.xml @@ -2,9 +2,101 @@ Inline styles demo - qweb_view - Demo email inline styles + + + + + +
+
+ + + + + + + +
+ + + +
+
+
+
+

Hello .

+
+
+

This e-mail styles are inline rendered although its template defines styles as embedded CSS!

+
+
+ +
+ + +
diff --git a/mail_inline_css/demo/demo_template.xml b/mail_inline_css/demo/demo_template.xml deleted file mode 100644 index 6171b77c..00000000 --- a/mail_inline_css/demo/demo_template.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - diff --git a/mail_inline_css/models/mail_template.py b/mail_inline_css/models/mail_template.py index 96fa7862..ff1f9210 100644 --- a/mail_inline_css/models/mail_template.py +++ b/mail_inline_css/models/mail_template.py @@ -3,22 +3,16 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import models - -try: - from premailer import Premailer -except (OSError, ImportError) as err: # pragma: no cover - import logging +from premailer import Premailer - _logger = logging.getLogger(__name__) - _logger.debug(err) +from odoo import models class MailTemplate(models.Model): _inherit = "mail.template" - def _render_template_postprocess(self, rendered): - rendered = super()._render_template_postprocess(rendered) + def _render_template_postprocess(self, model, rendered): + rendered = super()._render_template_postprocess(model, rendered) for res_id, html in rendered.items(): rendered[res_id] = self._premailer_apply_transform(html) return rendered diff --git a/mail_inline_css/readme/CONTRIBUTORS.md b/mail_inline_css/readme/CONTRIBUTORS.md index 04e458cf..3a131d66 100644 --- a/mail_inline_css/readme/CONTRIBUTORS.md +++ b/mail_inline_css/readme/CONTRIBUTORS.md @@ -11,3 +11,4 @@ - [Trobz](https://trobz.com): > - Son Ho \<\> + > - Khoi Vo \<\> diff --git a/mail_inline_css/readme/CREDITS.md b/mail_inline_css/readme/CREDITS.md index 291e14c8..d514b5fb 100644 --- a/mail_inline_css/readme/CREDITS.md +++ b/mail_inline_css/readme/CREDITS.md @@ -1,2 +1,2 @@ -The migration of this module from 15.0 to 16.0 was financially supported +The migration of this module from 16.0 to 18.0 was financially supported by Camptocamp diff --git a/mail_inline_css/static/description/index.html b/mail_inline_css/static/description/index.html index 09745d66..b638e32b 100644 --- a/mail_inline_css/static/description/index.html +++ b/mail_inline_css/static/description/index.html @@ -420,6 +420,7 @@

Contributors

@@ -427,7 +428,7 @@

Contributors

Other credits

-

The migration of this module from 15.0 to 16.0 was financially supported +

The migration of this module from 16.0 to 18.0 was financially supported by Camptocamp

diff --git a/mail_inline_css/tests/test_mail_inline_styles.py b/mail_inline_css/tests/test_mail_inline_styles.py index 09e1598e..2b5a2183 100644 --- a/mail_inline_css/tests/test_mail_inline_styles.py +++ b/mail_inline_css/tests/test_mail_inline_styles.py @@ -31,8 +31,8 @@ def assertNodeStyle(self, node, expected): self.assertEqual(self.parse_node_style(node), expected) def test_generate_mail(self): - res = self.mail_template.generate_email( - [self.demo_user.id], fields=["body_html"] + res = self.mail_template._generate_template( + [self.demo_user.id], render_fields=["body_html"] ) body_html_string = res[self.demo_user.id].get("body_html") html_node = self.to_xml_node(body_html_string)[0]