|
|
@ -7,6 +7,7 @@ from odoo import models |
|
|
|
from odoo.addons.base.ir.ir_mail_server import encode_header_param |
|
|
|
from lxml.html.soupparser import fromstring |
|
|
|
from lxml import etree |
|
|
|
from lxml.etree import tostring |
|
|
|
from base64 import b64encode |
|
|
|
from email.mime.image import MIMEImage |
|
|
|
from email import Encoders |
|
|
@ -69,14 +70,13 @@ class IrMailServer(models.Model): |
|
|
|
'web.base.url') |
|
|
|
src = base_url + img.get('src') |
|
|
|
response = requests.get(src) |
|
|
|
#content_base64 = b64encode(response.content) |
|
|
|
cid = uuid.uuid4().hex |
|
|
|
filename_rfc2047 = encode_header_param(cid) |
|
|
|
part = MIMEImage(response.content) |
|
|
|
part.set_param('name', filename_rfc2047) |
|
|
|
part.add_header( |
|
|
|
'Content-Disposition', |
|
|
|
'attachment', |
|
|
|
'inline', |
|
|
|
cid=cid, |
|
|
|
filename=filename_rfc2047, |
|
|
|
) |
|
|
@ -84,6 +84,6 @@ class IrMailServer(models.Model): |
|
|
|
Encoders.encode_base64(part) |
|
|
|
result.attach(part) |
|
|
|
img.set('src', 'cid:%s' % (cid)) |
|
|
|
msg.set_payload(etree.tostring(root)) |
|
|
|
msg.set_payload(b64encode(tostring(root))) |
|
|
|
_build_email_replace_img_src(result, attachments) |
|
|
|
return result |