social/mail_inline_css/models/mail.py

25 lines
653 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.

# coding: utf-8
# © 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(MailTemplate, self).generate_email(res_ids, fields=fields)
for id in res:
if res[id].get('body_html'):
res[id]['body_html'] = transform(res[id]['body_html'])
return res