diff --git a/mail_usability/__init__.py b/mail_usability/__init__.py index 35e7c96..9b42961 100644 --- a/mail_usability/__init__.py +++ b/mail_usability/__init__.py @@ -1,4 +1,2 @@ -# -*- coding: utf-8 -*- - from . import models from . import wizard diff --git a/mail_usability/__manifest__.py b/mail_usability/__manifest__.py index 07550ac..ca3c576 100644 --- a/mail_usability/__manifest__.py +++ b/mail_usability/__manifest__.py @@ -1,12 +1,11 @@ -# -*- coding: utf-8 -*- -# © 2016 Akretion (http://www.akretion.com) +# Copyright 2020 Akretion France (http://www.akretion.com) # @author Benoît Guillot # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Mail Usability', - 'version': '10.0.1.0.0', + 'version': '12.0.1.0.0', 'category': 'Base', 'license': 'AGPL-3', 'summary': 'Usability improvements on mails', @@ -29,6 +28,6 @@ Small usability improvements on mails: 'views/mail_view.xml', 'data/mail_data.xml', 'wizard/email_template_preview_view.xml', - ], + ], 'installable': True, } diff --git a/mail_usability/data/mail_data.xml b/mail_usability/data/mail_data.xml index f5499f4..538fb44 100644 --- a/mail_usability/data/mail_data.xml +++ b/mail_usability/data/mail_data.xml @@ -1,7 +1,6 @@ - - - + + Notification Email @@ -11,5 +10,4 @@ ${object.body | safe} - diff --git a/mail_usability/models/__init__.py b/mail_usability/models/__init__.py index 342436c..030741b 100644 --- a/mail_usability/models/__init__.py +++ b/mail_usability/models/__init__.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from . import mail from . import tools from . import mail_template diff --git a/mail_usability/models/mail.py b/mail_usability/models/mail.py index a17c91a..2fca1f2 100644 --- a/mail_usability/models/mail.py +++ b/mail_usability/models/mail.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2016-2017 Akretion (http://www.akretion.com) +# Copyright 2016-2017 Akretion France (http://www.akretion.com) # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -31,9 +30,7 @@ class MailThread(models.AbstractModel): if not 'mail_create_nosubscribe' in self._context: # Do not implicitly follow an object by just sending a message self = self.with_context(mail_create_nosubscribe=True) - return super(MailThread, - self.with_context(mail_create_nosubscribe=True) - ).message_post( - body=body, subject=subject, message_type=message_type, - subtype=subtype, parent_id=parent_id, attachments=attachments, - content_subtype=content_subtype, **kwargs) + return super(MailThread, self).message_post( + body=body, subject=subject, message_type=message_type, + subtype=subtype, parent_id=parent_id, attachments=attachments, + content_subtype=content_subtype, **kwargs) diff --git a/mail_usability/models/mail_message.py b/mail_usability/models/mail_message.py index f046bb5..8c97754 100644 --- a/mail_usability/models/mail_message.py +++ b/mail_usability/models/mail_message.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- -# Copyright 2019 Akretion (http://www.akretion.com). +# Copyright 2019 Akretion France (http://www.akretion.com) # @author Sébastien BEAU # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import api, fields, models +from odoo import models class MailMessage(models.Model): diff --git a/mail_usability/models/mail_template.py b/mail_usability/models/mail_template.py index f59dfd4..1cfdb0c 100644 --- a/mail_usability/models/mail_template.py +++ b/mail_usability/models/mail_template.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Akretion (http://www.akretion.com). +# Copyright 2018 Akretion France (http://www.akretion.com) # @author Sébastien BEAU # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/mail_usability/models/res_partner.py b/mail_usability/models/res_partner.py index dfbf693..86100a7 100644 --- a/mail_usability/models/res_partner.py +++ b/mail_usability/models/res_partner.py @@ -1,52 +1,28 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2016-2019 Akretion (http://www.akretion.com) +# Copyright 2016-2019 Akretion France (http://www.akretion.com) # @author Sébastien BEAU # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields +from odoo import models, fields, api class ResPartner(models.Model): _inherit = 'res.partner' - notify_email = fields.Selection( - selection_add=[ - ('all_except_notification', 'All Messages Except Notifications')], - default='all_except_notification') opt_out = fields.Boolean(track_visibility='onchange') - def _should_be_notify_by_email(self, message): - if message.message_type == 'notification': - if self.notify_email == 'always': - return True - else: - return False - else: - return True - - def _notify_by_email( - self, message, force_send=False, send_after_commit=True, - user_signature=True): - - # use an empty layout for notification by default + @api.model + def _notify(self, message, rdata, record, force_send=False, + send_after_commit=True, model_description=False, + mail_auto_delete=True): + # use an empty layout for notification by default if not self._context.get('custom_layout'): - self = self.with_context( - custom_layout='mail_usability.mail_template_notification') - - # Filter the partner that should receive the notification - filtered_partners = self.filtered( - lambda p: p._should_be_notify_by_email(message) - ) - - return super(ResPartner, filtered_partners)._notify_by_email( - message, force_send=force_send, - send_after_commit=send_after_commit, - user_signature=user_signature) - - def _notify_prepare_email_values(self, message): - res = super(ResPartner, self)._notify_prepare_email_values(message) + self = self.with_context( + custom_layout='mail_usability.mail_template_notification') # Never auto delete notification email # fucking to hard to debug when message have been delete - res['auto_delete'] = False - return res + mail_auto_delete = False + return super(ResPartner, self)._notify( + message=message, rdata=rdata, record=record, + force_send=force_send, send_after_commit=send_after_commit, + model_description=model_description, mail_auto_delete=mail_auto_delete) diff --git a/mail_usability/models/tools.py b/mail_usability/models/tools.py index 7d435c4..4c52393 100644 --- a/mail_usability/models/tools.py +++ b/mail_usability/models/tools.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Akretion (http://www.akretion.com). +# Copyright 2018 Akretion France (http://www.akretion.com) # @author Sébastien BEAU # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -41,5 +40,4 @@ if os.getenv('LOG_STYLE_SANITIZE'): for (key, val) in valid_styles.iteritems()) else: del el.attrib['style'] - import pdb; pdb.set_trace() _Cleaner.parse_style = parse_style diff --git a/mail_usability/views/mail_view.xml b/mail_usability/views/mail_view.xml index 6cbdc3f..1516153 100644 --- a/mail_usability/views/mail_view.xml +++ b/mail_usability/views/mail_view.xml @@ -1,21 +1,16 @@ - - - - mail.mail - - - - - - + + mail.mail + + + + + + + - - + diff --git a/mail_usability/wizard/__init__.py b/mail_usability/wizard/__init__.py index 39d98f0..134743a 100644 --- a/mail_usability/wizard/__init__.py +++ b/mail_usability/wizard/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import email_template_preview diff --git a/mail_usability/wizard/email_template_preview.py b/mail_usability/wizard/email_template_preview.py index 06df816..ae26a04 100644 --- a/mail_usability/wizard/email_template_preview.py +++ b/mail_usability/wizard/email_template_preview.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -# Copyright 2019 Akretion (http://www.akretion.com). +# Copyright 2019 Akretion France (http://www.akretion.com) # @author Sébastien BEAU # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -26,10 +25,10 @@ class TemplatePreview(models.TransientModel): model = self.env['ir.model'].browse(result['model_id']) return [(model.model, model.name)] else: - models = self.env['ir.model'].search([('state', '!=', 'manual')]) - return [(model.model, model.name) - for model in models - if not model.model.startswith('ir.')] + ir_models = self.env['ir.model'].search([('state', '!=', 'manual')]) + return [(ir_model.model, ir_model.name) + for ir_model in ir_models + if not ir_model.model.startswith('ir.')] @api.depends('object_id') def _compute_res_id(self): diff --git a/mail_usability/wizard/email_template_preview_view.xml b/mail_usability/wizard/email_template_preview_view.xml index 494b92e..1d64c9e 100644 --- a/mail_usability/wizard/email_template_preview_view.xml +++ b/mail_usability/wizard/email_template_preview_view.xml @@ -1,24 +1,24 @@ - - email_template.preview - - - - True + + email_template.preview + + + + True + + + + +
+
- - - - - -
+