From 9f6d72034fca636e7e8d8d22c6714af998cd9009 Mon Sep 17 00:00:00 2001 From: ernesto Date: Mon, 5 Nov 2018 11:26:01 -0500 Subject: [PATCH] [MIG] mail_tracking: Migration to 12.0 --- mail_tracking/README.rst | 99 ++-- mail_tracking/__manifest__.py | 3 +- mail_tracking/models/__init__.py | 1 + mail_tracking/models/ir_mail_server.py | 1 - mail_tracking/models/mail_bounced_mixin.py | 43 ++ mail_tracking/models/mail_mail.py | 4 +- mail_tracking/models/mail_tracking_email.py | 16 +- mail_tracking/models/res_partner.py | 21 +- mail_tracking/readme/CONTRIBUTORS.rst | 7 + mail_tracking/readme/CREDITS.rst | 7 + mail_tracking/readme/DESCRIPTION.rst | 3 + mail_tracking/readme/INSTALL.rst | 5 + mail_tracking/readme/USAGE.rst | 41 ++ mail_tracking/static/description/index.html | 470 ++++++++++++++++++ mail_tracking/static/src/js/mail_tracking.js | 65 ++- .../static/src/xml/mail_tracking.xml | 54 +- mail_tracking/tests/__init__.py | 2 - mail_tracking/tests/test_mail_tracking.py | 18 +- .../views/mail_tracking_email_view.xml | 8 +- .../views/mail_tracking_event_view.xml | 14 +- mail_tracking/views/res_partner_view.xml | 6 +- 21 files changed, 758 insertions(+), 130 deletions(-) create mode 100644 mail_tracking/models/mail_bounced_mixin.py create mode 100644 mail_tracking/readme/CONTRIBUTORS.rst create mode 100644 mail_tracking/readme/CREDITS.rst create mode 100644 mail_tracking/readme/DESCRIPTION.rst create mode 100644 mail_tracking/readme/INSTALL.rst create mode 100644 mail_tracking/readme/USAGE.rst create mode 100644 mail_tracking/static/description/index.html diff --git a/mail_tracking/README.rst b/mail_tracking/README.rst index fb4118ae..b13c35de 100644 --- a/mail_tracking/README.rst +++ b/mail_tracking/README.rst @@ -1,15 +1,39 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg +============== +Email tracking +============== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 - -============= -Mail tracking -============= +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github + :target: https://github.com/OCA/social/tree/12.0/mail_tracking + :alt: OCA/social +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/social-12-0/social-12-0-mail_tracking + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/205/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| This module shows email notification tracking status for any messages in mail thread (chatter). Each notified partner will have an intuitive icon just right to his name. +**Table of contents** + +.. contents:: + :local: + Installation ============ @@ -28,22 +52,22 @@ status icon will appear just right to name of notified partner. These are all available status icons: -.. |sent| image:: static/src/img/sent.png +.. |sent| image:: mail_tracking/static/src/img/sent.png :width: 10px -.. |delivered| image:: static/src/img/delivered.png +.. |delivered| image:: mail_tracking/static/src/img/delivered.png :width: 15px -.. |opened| image:: static/src/img/opened.png +.. |opened| image:: mail_tracking/static/src/img/opened.png :width: 15px -.. |error| image:: static/src/img/error.png +.. |error| image:: mail_tracking/static/src/img/error.png :width: 10px -.. |waiting| image:: static/src/img/waiting.png +.. |waiting| image:: mail_tracking/static/src/img/waiting.png :width: 10px -.. |unknown| image:: static/src/img/unknown.png +.. |unknown| image:: mail_tracking/static/src/img/unknown.png :width: 10px |unknown| **Unknown**: No email tracking info available. Maybe this notified partner has 'Receive Inbox Notifications by Email' == 'Never' @@ -58,11 +82,6 @@ These are all available status icons: |opened| **Opened**: Opened by partner - -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/205/11.0 - If you want to see all tracking emails and events you can go to * Settings > Technical > Email > Tracking emails @@ -72,14 +91,35 @@ If you want to see all tracking emails and events you can go to Bug Tracker =========== -Bugs are tracked on `GitHub Issues -`_. In case of trouble, please -check there if your issue has already been reported. If you spotted it first, -help us smashing it by providing a detailed and welcomed feedback. +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Pedro M. Baeza + * Antonio Espinosa + * David Vidal + * Ernesto Tejeda + * Rafael Blasco + +Other credits +~~~~~~~~~~~~~ + Images ------ @@ -88,26 +128,19 @@ Images `_ for `the icon `_. -Contributors ------------- - -* `Tecnativa `_: +Maintainers +~~~~~~~~~~~ - * Pedro M. Baeza - * Antonio Espinosa - * David Vidal - -Maintainer ----------- +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit https://odoo-community.org. +This module is part of the `OCA/social `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_tracking/__manifest__.py b/mail_tracking/__manifest__.py index 030c0f67..7ea169ad 100644 --- a/mail_tracking/__manifest__.py +++ b/mail_tracking/__manifest__.py @@ -1,11 +1,12 @@ # Copyright 2016 Antonio Espinosa - # Copyright 2018 David Vidal - +# Copyright 2018 Tecnativa - Ernesto Tejeda # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Email tracking", "summary": "Email tracking system for all mails sent", - "version": "11.0.1.1.0", + "version": "12.0.1.0.0", "category": "Social Network", "website": "http://github.com/OCA/social", "author": "Tecnativa, " diff --git a/mail_tracking/models/__init__.py b/mail_tracking/models/__init__.py index f0ebf2ac..847f98f0 100644 --- a/mail_tracking/models/__init__.py +++ b/mail_tracking/models/__init__.py @@ -1,6 +1,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import ir_mail_server +from . import mail_bounced_mixin from . import mail_mail from . import mail_message from . import mail_tracking_email diff --git a/mail_tracking/models/ir_mail_server.py b/mail_tracking/models/ir_mail_server.py index 8902ac06..6aaf465b 100644 --- a/mail_tracking/models/ir_mail_server.py +++ b/mail_tracking/models/ir_mail_server.py @@ -80,7 +80,6 @@ class IrMailServer(models.Model): except Exception as e: if tracking_email: tracking_email.smtp_error(self, smtp_server_used, e) - raise if message_id and tracking_email: vals = tracking_email._tracking_sent_prepare( self, smtp_server_used, message, message_id) diff --git a/mail_tracking/models/mail_bounced_mixin.py b/mail_tracking/models/mail_bounced_mixin.py new file mode 100644 index 00000000..d84069cd --- /dev/null +++ b/mail_tracking/models/mail_bounced_mixin.py @@ -0,0 +1,43 @@ +# Copyright 2018 Tecnativa - Ernesto Tejeda +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import logging + +from odoo import api, fields, models + +_logger = logging.getLogger(__name__) + + +class MailBouncedMixin(models.AbstractModel): + """ A mixin class to use if you want to add is_bounced flag on a model. + The field '_primary_email' must be overridden in the model that inherit + the mixin and must contain the email field of the model. + """ + + _name = 'mail.bounced.mixin' + _description = 'Mail bounced mixin' + _primary_email = ['email'] + + email_bounced = fields.Boolean(index=True) + + @api.multi + def email_bounced_set(self, tracking_emails, reason, event=None): + """Inherit this method to make any other actions to the model that + inherit the mixin""" + partners = self.filtered(lambda r: not r.email_bounced) + return partners.write({'email_bounced': True}) + + def write(self, vals): + [email_field] = self._primary_email + if email_field not in vals: + return super(MailBouncedMixin, self).write(vals) + email = vals[email_field].lower() if vals[email_field] else False + mte_obj = self.env['mail.tracking.email'] + if not mte_obj.email_is_bounced(email): + vals['email_bounced'] = False + return super(MailBouncedMixin, self).write(vals) + res = mte_obj._email_last_tracking_state(email) + tracking = mte_obj.browse(res[0].get('id')) + event = tracking.tracking_event_ids[:1] + self.email_bounced_set(tracking, event.error_details, event) + return super(MailBouncedMixin, self).write(vals) diff --git a/mail_tracking/models/mail_mail.py b/mail_tracking/models/mail_mail.py index 2625f4c3..2342d1c8 100644 --- a/mail_tracking/models/mail_mail.py +++ b/mail_tracking/models/mail_mail.py @@ -27,8 +27,8 @@ class MailMail(models.Model): 'sender': self.email_from, } - def send_get_email_dict(self, partner=None): - email = super(MailMail, self).send_get_email_dict(partner=partner) + def _send_prepare_values(self, partner=None): + email = super(MailMail, self)._send_prepare_values(partner=partner) vals = self._tracking_email_prepare(partner, email) tracking_email = self.env['mail.tracking.email'].sudo().create(vals) return tracking_email.tracking_img_add(email) diff --git a/mail_tracking/models/mail_tracking_email.py b/mail_tracking/models/mail_tracking_email.py index a69e3210..3a2e9b35 100644 --- a/mail_tracking/models/mail_tracking_email.py +++ b/mail_tracking/models/mail_tracking_email.py @@ -94,12 +94,16 @@ class MailTrackingEmail(models.Model): @api.model def email_is_bounced(self, email): - if email: - return self.search_count([ - ('recipient_address', '=', email.lower()), - ('state', 'in', ('error', 'rejected', 'spam', 'bounced')), - ]) > 0 - return False + if not email: + return False + res = self._email_last_tracking_state(email) + return res and res[0].get('state', '') in ['rejected', 'error', + 'spam', 'bounced'] + + @api.model + def _email_last_tracking_state(self, email): + return self.search_read([('recipient_address', '=', email.lower())], + ['state'], limit=1, order='time DESC') @api.model def email_score_from_email(self, email): diff --git a/mail_tracking/models/res_partner.py b/mail_tracking/models/res_partner.py index 6c6a319b..7dbee8fd 100644 --- a/mail_tracking/models/res_partner.py +++ b/mail_tracking/models/res_partner.py @@ -5,15 +5,13 @@ from odoo import models, api, fields class ResPartner(models.Model): - _inherit = 'res.partner' + _name = 'res.partner' + _inherit = ['res.partner', 'mail.bounced.mixin'] # tracking_emails_count and email_score are non-store fields in order # to improve performance - # email_bounced is store=True and index=True field in order to filter - # in tree view for processing bounces easier tracking_emails_count = fields.Integer( compute='_compute_tracking_emails_count', readonly=True) - email_bounced = fields.Boolean(index=True) email_score = fields.Float(compute='_compute_email_score', readonly=True) @api.depends('email') @@ -32,18 +30,3 @@ class ResPartner(models.Model): ('recipient_address', '=', partner.email.lower()) ]) partner.tracking_emails_count = count - - @api.multi - def email_bounced_set(self, tracking_emails, reason, event=None): - """Inherit this method to make any other actions to partners""" - partners = self.filtered(lambda r: not r.email_bounced) - return partners.write({'email_bounced': True}) - - def write(self, vals): - email = vals.get('email') - if email is not None: - vals['email'] = email.lower() if email else False - vals['email_bounced'] = ( - bool(email) and - self.env['mail.tracking.email'].email_is_bounced(email)) - return super(ResPartner, self).write(vals) diff --git a/mail_tracking/readme/CONTRIBUTORS.rst b/mail_tracking/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..81d19537 --- /dev/null +++ b/mail_tracking/readme/CONTRIBUTORS.rst @@ -0,0 +1,7 @@ +* `Tecnativa `_: + + * Pedro M. Baeza + * Antonio Espinosa + * David Vidal + * Ernesto Tejeda + * Rafael Blasco diff --git a/mail_tracking/readme/CREDITS.rst b/mail_tracking/readme/CREDITS.rst new file mode 100644 index 00000000..efa5e9d4 --- /dev/null +++ b/mail_tracking/readme/CREDITS.rst @@ -0,0 +1,7 @@ +Images +------ + +* Odoo Community Association: `Icon `_. +* Thanks to `LlubNek `_ and `Openclipart + `_ for `the icon + `_. diff --git a/mail_tracking/readme/DESCRIPTION.rst b/mail_tracking/readme/DESCRIPTION.rst new file mode 100644 index 00000000..d8dbc8bf --- /dev/null +++ b/mail_tracking/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module shows email notification tracking status for any messages in +mail thread (chatter). Each notified partner will have an intuitive icon just +right to his name. diff --git a/mail_tracking/readme/INSTALL.rst b/mail_tracking/readme/INSTALL.rst new file mode 100644 index 00000000..cb09d4c4 --- /dev/null +++ b/mail_tracking/readme/INSTALL.rst @@ -0,0 +1,5 @@ +If you're using a multi-database installation (with or without dbfilter option) +where /web/databse/selector returns a list of more than one database, then +you need to add ``mail_tracking`` addon to wide load addons list +(by default, only ``web`` addon), setting ``--load`` option. +For example, ``--load=web,mail_tracking`` diff --git a/mail_tracking/readme/USAGE.rst b/mail_tracking/readme/USAGE.rst new file mode 100644 index 00000000..87df760b --- /dev/null +++ b/mail_tracking/readme/USAGE.rst @@ -0,0 +1,41 @@ +When user sends a message in mail_thread (chatter), for instance in partner +form, then an email tracking is created for each email notification. Then a +status icon will appear just right to name of notified partner. + +These are all available status icons: + +.. |sent| image:: mail_tracking/static/src/img/sent.png + :width: 10px + +.. |delivered| image:: mail_tracking/static/src/img/delivered.png + :width: 15px + +.. |opened| image:: mail_tracking/static/src/img/opened.png + :width: 15px + +.. |error| image:: mail_tracking/static/src/img/error.png + :width: 10px + +.. |waiting| image:: mail_tracking/static/src/img/waiting.png + :width: 10px + +.. |unknown| image:: mail_tracking/static/src/img/unknown.png + :width: 10px + +|unknown| **Unknown**: No email tracking info available. Maybe this notified partner has 'Receive Inbox Notifications by Email' == 'Never' + +|waiting| **Waiting**: Waiting to be sent + +|error| **Error**: Error while sending + +|sent| **Sent**: Sent to SMTP server configured + +|delivered| **Delivered**: Delivered to final MX server + +|opened| **Opened**: Opened by partner + +If you want to see all tracking emails and events you can go to + +* Settings > Technical > Email > Tracking emails +* Settings > Technical > Email > Tracking events + diff --git a/mail_tracking/static/description/index.html b/mail_tracking/static/description/index.html new file mode 100644 index 00000000..90220f00 --- /dev/null +++ b/mail_tracking/static/description/index.html @@ -0,0 +1,470 @@ + + + + + + +Email tracking + + + +
+

Email tracking

+ + +

Beta License: AGPL-3 OCA/social Translate me on Weblate Try me on Runbot

+

This module shows email notification tracking status for any messages in +mail thread (chatter). Each notified partner will have an intuitive icon just +right to his name.

+

Table of contents

+ +
+

Installation

+

If you’re using a multi-database installation (with or without dbfilter option) +where /web/databse/selector returns a list of more than one database, then +you need to add mail_tracking addon to wide load addons list +(by default, only web addon), setting --load option. +For example, --load=web,mail_tracking

+
+
+

Usage

+

When user sends a message in mail_thread (chatter), for instance in partner +form, then an email tracking is created for each email notification. Then a +status icon will appear just right to name of notified partner.

+

These are all available status icons:

+

unknown Unknown: No email tracking info available. Maybe this notified partner has ‘Receive Inbox Notifications by Email’ == ‘Never’

+

waiting Waiting: Waiting to be sent

+

error Error: Error while sending

+

sent Sent: Sent to SMTP server configured

+

delivered Delivered: Delivered to final MX server

+

opened Opened: Opened by partner

+

If you want to see all tracking emails and events you can go to

+
    +
  • Settings > Technical > Email > Tracking emails
  • +
  • Settings > Technical > Email > Tracking events
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Pedro M. Baeza
    • +
    • Antonio Espinosa
    • +
    • David Vidal
    • +
    • Ernesto Tejeda
    • +
    • Rafael Blasco
    • +
    +
  • +
+
+
+

Other credits

+
+

Images

+ +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/social project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/mail_tracking/static/src/js/mail_tracking.js b/mail_tracking/static/src/js/mail_tracking.js index a06da95e..828ba780 100644 --- a/mail_tracking/static/src/js/mail_tracking.js +++ b/mail_tracking/static/src/js/mail_tracking.js @@ -6,33 +6,60 @@ odoo.define('mail_tracking.partner_tracking', function(require){ "use strict"; var core = require('web.core'); - var session = require('web.session'); - var data = require('web.data'); var ActionManager = require('web.ActionManager'); - var chat_manager = require('mail.chat_manager'); - var ChatThread = require('mail.ChatThread'); - var Chatter = require('mail.Chatter'); + var AbstractMessage = require('mail.model.AbstractMessage'); + var Message = require('mail.model.Message'); + var ThreadWidget = require('mail.widget.Thread'); var _t = core._t; - // chat_manager is a simple dictionary, not an OdooClass - chat_manager._make_message_super = chat_manager.make_message; - chat_manager.make_message = function(data) { - var msg = this._make_message_super(data); - msg.partner_trackings = data.partner_trackings || []; - return msg; - }; + AbstractMessage.include({ + /** + * Messages do not have any PartnerTrackings. + * + * @return {boolean} + */ + hasPartnerTrackings: function () { + return false; + }, + }); + + Message.include({ + init: function (parent, data, emojis) { + this._super.apply(this, arguments); + this._partnerTrackings = data.partner_trackings || []; + }, - ChatThread.include({ - events: _.extend(ChatThread.prototype.events, { + /** + * State whether this message contains some PartnerTrackings values + * + * @override + * @return {boolean} + */ + hasPartnerTrackings: function () { + return !!(this._partnerTrackings && (this._partnerTrackings.length > 0)); + }, + + /** + * Get the PartnerTrackings values of this message + * If this message has no PartnerTrackings values, returns [] + * + * @override + * @return {Object[]} + */ + getPartnerTrackings: function () { + if (!this.hasPartnerTrackings()) { + return []; + } + return this._partnerTrackings; + }, + }); + + ThreadWidget.include({ + events: _.extend(ThreadWidget.prototype.events, { 'click .o_mail_action_tracking_partner': 'on_tracking_partner_click', 'click .o_mail_action_tracking_status': 'on_tracking_status_click', }), - _preprocess_message: function (message) { - var msg = this._super.apply(this, arguments); - msg.partner_trackings = msg.partner_trackings || []; - return msg; - }, on_tracking_partner_click: function (event) { var partner_id = this.$el.find(event.currentTarget).data('partner'); var state = { diff --git a/mail_tracking/static/src/xml/mail_tracking.xml b/mail_tracking/static/src/xml/mail_tracking.xml index 5bc278da..27d79883 100644 --- a/mail_tracking/static/src/xml/mail_tracking.xml +++ b/mail_tracking/static/src/xml/mail_tracking.xml @@ -40,33 +40,35 @@ - - -

- To: - - - - - + + + +

+ To: + + + + - + + + + + + + + + + + + + - - - - - - - - - - - - - -

+

+
diff --git a/mail_tracking/tests/__init__.py b/mail_tracking/tests/__init__.py index 03209262..d40d444b 100644 --- a/mail_tracking/tests/__init__.py +++ b/mail_tracking/tests/__init__.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Copyright 2016 Antonio Espinosa - # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -# flake8: noqa from . import test_mail_tracking diff --git a/mail_tracking/tests/test_mail_tracking.py b/mail_tracking/tests/test_mail_tracking.py index 7dcb65c6..55166408 100644 --- a/mail_tracking/tests/test_mail_tracking.py +++ b/mail_tracking/tests/test_mail_tracking.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2016 Antonio Espinosa - # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). @@ -9,7 +8,7 @@ from odoo import http from odoo.tests.common import TransactionCase from ..controllers.main import MailTrackingController, BLANK -mock_send_email = ('odoo.addons.base.ir.ir_mail_server.' +mock_send_email = ('odoo.addons.base.models.ir_mail_server.' 'IrMailServer.send_email') @@ -50,10 +49,6 @@ class TestMailTracking(TransactionCase): http.request = self.last_request return super(TestMailTracking, self).tearDown(*args, **kwargs) - def test_email_lower(self): - self.recipient.write({'email': 'UPPER@example.com'}) - self.assertEqual('upper@example.com', self.recipient.email) - def test_empty_email(self): self.recipient.write({'email_bounced': True}) self.recipient.write({'email': False}) @@ -61,7 +56,6 @@ class TestMailTracking(TransactionCase): self.assertEqual(False, self.recipient.email_bounced) self.recipient.write({'email_bounced': True}) self.recipient.write({'email': ''}) - self.assertEqual(False, self.recipient.email) self.assertEqual(False, self.recipient.email_bounced) self.assertEqual( False, @@ -87,6 +81,7 @@ class TestMailTracking(TransactionCase): 'partner_ids': [(4, self.recipient.id)], 'body': '

This is a test message

', }) + message._notify(message, {}, force_send=True) # Search tracking created tracking_email = self.env['mail.tracking.email'].search([ ('mail_message_id', '=', message.id), @@ -303,6 +298,15 @@ class TestMailTracking(TransactionCase): self.assertEqual('bounced', tracking.state) self.assertEqual(0.0, self.recipient.email_score) + def test_bounce_new_partner(self): + mail, tracking = self.mail_send(self.recipient.email) + tracking.event_create('hard_bounce', {}) + new_partner = self.env['res.partner'].create({ + 'name': 'Test New Partner', + }) + new_partner.email = self.recipient.email + self.assertTrue(new_partner.email_bounced) + def test_recordset_email_score(self): """For backwords compatibility sake""" trackings = self.env['mail.tracking.email'] diff --git a/mail_tracking/views/mail_tracking_email_view.xml b/mail_tracking/views/mail_tracking_email_view.xml index a2a95f5f..fc97c76c 100644 --- a/mail_tracking/views/mail_tracking_email_view.xml +++ b/mail_tracking/views/mail_tracking_email_view.xml @@ -94,10 +94,10 @@ domain="[('state', 'in', ('error', 'rejected', 'spam', 'bounced', 'soft-bounced'))]"/> - - - - + + + + diff --git a/mail_tracking/views/mail_tracking_event_view.xml b/mail_tracking/views/mail_tracking_event_view.xml index 4298e4ec..9f3b8737 100644 --- a/mail_tracking/views/mail_tracking_event_view.xml +++ b/mail_tracking/views/mail_tracking_event_view.xml @@ -96,13 +96,13 @@ context="{'event_error_filter': True}"/> - - - - - - - + + + + + + + diff --git a/mail_tracking/views/res_partner_view.xml b/mail_tracking/views/res_partner_view.xml index 5e6a92e4..f1758dae 100644 --- a/mail_tracking/views/res_partner_view.xml +++ b/mail_tracking/views/res_partner_view.xml @@ -6,7 +6,7 @@ Partner Form with tracking emails res.partner - 46 + 46
@@ -22,12 +22,12 @@ string="Tracking emails"/>
- + - +