social/mail_inline_css/models/mail.py

23 lines
581 B
Python
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

# Copyright 2017 David BEAL @ Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from odoo import models
_logger = logging.getLogger(__name__)
try:
from premailer import transform
except (ImportError, IOError) as err:
_logger.debug(err)
class MailTemplate(models.Model):
_inherit = 'mail.template'
def generate_email(self, res_ids, fields=None):
res = super().generate_email(res_ids, fields=fields)
if 'body_html' in res:
res['body_html'] = transform(res['body_html'])
return res