From 9e811c608c6498acb30b94edb12d9a51006d89ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 8 Jun 2018 11:37:48 +0200 Subject: [PATCH 1/9] [IMP] test_mail: add a tag on performance tests It allow to easily recompute performance-related tests when working on mail thread features. Tags are awesome. --- addons/test_mail/tests/test_performance.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/test_mail/tests/test_performance.py b/addons/test_mail/tests/test_performance.py index 1e8b594e462..acf3c99bc60 100644 --- a/addons/test_mail/tests/test_performance.py +++ b/addons/test_mail/tests/test_performance.py @@ -4,9 +4,11 @@ from email.utils import formataddr from odoo.tests.common import TransactionCase, users, warmup +from odoo.tests import tagged from odoo.tools import mute_logger +@tagged('mail_performance') class TestMailPerformance(TransactionCase): def setUp(self): @@ -113,6 +115,7 @@ class TestMailPerformance(TransactionCase): }) +@tagged('mail_performance') class TestAdvMailPerformance(TransactionCase): def setUp(self): @@ -295,6 +298,7 @@ class TestAdvMailPerformance(TransactionCase): record.message_subscribe(partner_ids=self.user_test.partner_id.ids, subtype_ids=subtype_ids) +@tagged('mail_performance') class TestHeavyMailPerformance(TransactionCase): def setUp(self): From caf400fa7c0e0ef60fb79e889931970e6fa35416 Mon Sep 17 00:00:00 2001 From: Pratima Gupta Date: Mon, 7 May 2018 15:53:36 +0530 Subject: [PATCH 2/9] [IMP] tools: allow more items in styling white list when sanitizing Some of the templates Odoo proposed do not display well on all email readers as too much styling attributes are sanitized. This commit adds some styling in the white list to allow having stylized templates while still having a coherent white list. This commit is related to task 51122 (and PR #24052). --- odoo/tools/mail.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/odoo/tools/mail.py b/odoo/tools/mail.py index 3981f4b62cd..2da0684c015 100644 --- a/odoo/tools/mail.py +++ b/odoo/tools/mail.py @@ -44,13 +44,13 @@ class _Cleaner(clean.Cleaner): _style_whitelist = [ 'font-size', 'font-family', 'font-weight', 'background-color', 'color', 'text-align', - 'line-height', 'letter-spacing', 'text-transform', 'text-decoration', + 'line-height', 'letter-spacing', 'text-transform', 'text-decoration', 'opacity', 'float', 'vertical-align', 'padding', 'padding-top', 'padding-left', 'padding-bottom', 'padding-right', 'margin', 'margin-top', 'margin-left', 'margin-bottom', 'margin-right', # box model - 'border', 'border-color', 'border-radius', 'border-style', 'border-width', - 'height', 'margin', 'padding', 'width', 'max-width', 'min-width', + 'border', 'border-color', 'border-radius', 'border-style', 'border-width', 'border-top', + 'height', 'width', 'max-width', 'min-width', 'min-height', # tables 'border-collapse', 'border-spacing', 'caption-side', 'empty-cells', 'table-layout'] From 1184f7872d6776d744c7a516d3fcac99467f1c19 Mon Sep 17 00:00:00 2001 From: Pratima Gupta Date: Wed, 14 Mar 2018 11:16:17 +0530 Subject: [PATCH 3/9] [IMP] mail: ease the use and specification of notification emails layout This commit proposes to ease the use and specification of layout used to encapsulate email body when sending notification emails. This is done through two means * message_post_with_template now supports the custom layout parameter that allows to set the layout to use when sending notification emails in the message_post process. We have to rely on the context as it is the current way of using it in the composer. It is likely to change in a near future; * composer now supports through context (as we have no other choice) specific notification values to give to the notification layout rendering; This commit is related to task 51122 (and PR #24052). --- addons/mail/models/mail_thread.py | 2 ++ addons/mail/models/res_partner.py | 2 +- addons/mail/wizard/mail_compose_message.py | 10 ++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 4f89da3b69e..a70e4d65205 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -2076,6 +2076,7 @@ class MailThread(models.AbstractModel): kwargs['message_type'] = 'notification' res_id = kwargs.get('res_id', self.ids and self.ids[0] or 0) res_ids = kwargs.get('res_id') and [kwargs['res_id']] or self.ids + notif_layout = kwargs.pop('notif_layout', None) # Create the composer composer = self.env['mail.compose.message'].with_context( @@ -2086,6 +2087,7 @@ class MailThread(models.AbstractModel): default_model=kwargs.get('model', self._name), default_res_id=res_id, default_template_id=template_id, + custom_layout=notif_layout, ).create(kwargs) # Simulate the onchange (like trigger in form the view) only # when having a template in single-email mode diff --git a/addons/mail/models/res_partner.py b/addons/mail/models/res_partner.py index 07bee0bb6e6..d9fb69cecb2 100644 --- a/addons/mail/models/res_partner.py +++ b/addons/mail/models/res_partner.py @@ -85,7 +85,7 @@ class Partner(models.Model): 'signature': signature, 'website_url': website_url, 'company': company, - 'model_name': model_name, + 'model_description': model_name, 'record': record, 'record_name': record_name, 'tracking_values': tracking, diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index e16cd71815b..905c7194083 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -198,6 +198,7 @@ class MailComposer(models.TransientModel): """ Process the wizard content and proceed with sending the related email(s), rendering any template patterns on the fly if needed. """ notif_layout = self._context.get('custom_layout') + ctx_notif_values = self._context.get('notif_values', {}) for wizard in self: # Duplicate attachments linked to the email.template. # Indeed, basic mail.compose.message wizard duplicates attachments in mass @@ -246,14 +247,15 @@ class MailComposer(models.TransientModel): if wizard.composition_mode == 'mass_mail': batch_mails |= Mail.create(mail_values) else: + notif_values = dict( + add_sign=not bool(wizard.template_id), + mail_auto_delete=wizard.template_id.auto_delete if wizard.template_id else False, + **ctx_notif_values) post_params = dict( message_type=wizard.message_type, subtype_id=subtype_id, notif_layout=notif_layout, - notif_values={ - 'add_sign': not bool(wizard.template_id), - 'mail_auto_delete': wizard.template_id.auto_delete if wizard.template_id else False, - }, + notif_values=notif_values, **mail_values) if ActiveModel._name == 'mail.thread' and wizard.model: post_params['model'] = wizard.model From cc63d420b87fd509360a6f23cb749b1762adc4aa Mon Sep 17 00:00:00 2001 From: Pratima Gupta Date: Mon, 14 May 2018 17:30:26 +0530 Subject: [PATCH 4/9] [IMP] mail: update light notification template for a cleaner design * increase logo size, because big logos are necessary; * correctly set cellpadding / spacing to 0 to avoid loosing some pixels when having several embedded tables; * remove summary mail_notification as it should be used only to some customer-specific part of emails; This commit is related to task 51122 (and PR #24052). --- addons/mail/data/mail_data.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index fbbc41f5202..799e8eb6d76 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -158,20 +158,20 @@