From 597293791f609186349bd09e3cb7a7ef2c83a1e9 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 +- requirements.txt | 2 + 10 files changed, 118 insertions(+), 119 deletions(-) delete mode 100644 mail_inline_css/demo/demo_template.xml create mode 100644 requirements.txt diff --git a/mail_inline_css/README.rst b/mail_inline_css/README.rst index ddb3647efd..1564d4ab51 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 1f94d47d00..220e822eff 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 57211f9779..a26086e5ca 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 6171b77c7c..0000000000 --- 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 96fa78629f..ff1f921077 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 04e458cf59..3a131d6633 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 291e14c81e..d514b5fb04 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 09745d664d..b638e32b41 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 09e1598e50..2b5a218336 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] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000..4fb8946e1e --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# generated from manifests external_dependencies +premailer