[IMP] add some extra style css support and add a debugger mode. Update readme
This commit is contained in:
@@ -8,3 +8,13 @@ Take back the control on your email
|
||||
- add the option 'All Messages Except Notifications' on partner and use it by default to avoid sending unwanted mail to partner
|
||||
- better email preview, allow to select between the whole database object and not only the last 10
|
||||
- use a light template version for notification without link (link should be explicit)
|
||||
- add some additional style in the white list when santizing html field (see tools.py)
|
||||
- make the email template by default not 'auto_delete'
|
||||
|
||||
## TIPS
|
||||
|
||||
Never, never tick the 'auto_delete' on mail template because it fucking hard to debug
|
||||
and understand what have been sent (we should create a module with a crontask, that drop them latter)
|
||||
|
||||
If the template of mail do not look like the same when saving it in odoo, maybe the sanitize style have drop some balise
|
||||
please run odoo with "LOG_STYLE_SANITIZE=True odoo" to understand what have been drop, magic warning logger will tell you everthing
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import mail
|
||||
from . import tools
|
||||
from . import mail_template
|
||||
|
||||
45
mail_usability/tools.py
Normal file
45
mail_usability/tools.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 Akretion (http://www.akretion.com).
|
||||
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.tools.mail import _Cleaner
|
||||
import os
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
_Cleaner._style_whitelist += [
|
||||
'word-wrap',
|
||||
'display'
|
||||
'border-top',
|
||||
'border-bottom',
|
||||
'border-left',
|
||||
'border-right',
|
||||
'text-transform',
|
||||
]
|
||||
|
||||
|
||||
if os.getenv('LOG_STYLE_SANITIZE'):
|
||||
# Monkey patch the parse style method to debug
|
||||
# the missing style
|
||||
def parse_style(self, el):
|
||||
attributes = el.attrib
|
||||
styling = attributes.get('style')
|
||||
if styling:
|
||||
valid_styles = {}
|
||||
styles = self._style_re.findall(styling)
|
||||
for style in styles:
|
||||
if style[0].lower() in self._style_whitelist:
|
||||
valid_styles[style[0].lower()] = style[1]
|
||||
# START HACK
|
||||
else:
|
||||
_logger.warning('Remove style %s %s', *style)
|
||||
# END HACK
|
||||
if valid_styles:
|
||||
el.attrib['style'] = '; '.join(
|
||||
'%s:%s' % (key, val)
|
||||
for (key, val) in valid_styles.iteritems())
|
||||
else:
|
||||
del el.attrib['style']
|
||||
import pdb; pdb.set_trace()
|
||||
_Cleaner.parse_style = parse_style
|
||||
Reference in New Issue
Block a user