diff --git a/mail_tracking/README.rst b/mail_tracking/README.rst index 40ba269c..3eb00cc7 100644 --- a/mail_tracking/README.rst +++ b/mail_tracking/README.rst @@ -63,7 +63,7 @@ These are all available status icons: .. 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/9.0 + :target: https://runbot.odoo-community.org/runbot/205/10.0 If you want to see all tracking emails and events you can go to diff --git a/mail_tracking/__manifest__.py b/mail_tracking/__manifest__.py index 68ae3b9a..acb11080 100644 --- a/mail_tracking/__manifest__.py +++ b/mail_tracking/__manifest__.py @@ -5,14 +5,14 @@ { "name": "Email tracking", "summary": "Email tracking system for all mails sent", - "version": "9.0.1.0.0", + "version": "10.0.1.0.0", "category": "Social Network", "website": "http://www.tecnativa.com", "author": "Tecnativa, " "Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, - 'installable': False, + 'installable': True, "depends": [ "decimal_precision", "mail", diff --git a/mail_tracking/controllers/main.py b/mail_tracking/controllers/main.py index da14949d..0394070f 100644 --- a/mail_tracking/controllers/main.py +++ b/mail_tracking/controllers/main.py @@ -4,7 +4,7 @@ import werkzeug from psycopg2 import OperationalError -from openerp import api, http, registry, SUPERUSER_ID +from odoo import api, http, registry, SUPERUSER_ID import logging _logger = logging.getLogger(__name__) diff --git a/mail_tracking/data/tracking_data.xml b/mail_tracking/data/tracking_data.xml index 4bcb2cb8..320ca782 100644 --- a/mail_tracking/data/tracking_data.xml +++ b/mail_tracking/data/tracking_data.xml @@ -1,13 +1,9 @@ - - - - - MailTracking Timestamp - 6 - - - - + + + MailTracking Timestamp + 6 + + diff --git a/mail_tracking/models/ir_mail_server.py b/mail_tracking/models/ir_mail_server.py index e364a570..2908ee77 100644 --- a/mail_tracking/models/ir_mail_server.py +++ b/mail_tracking/models/ir_mail_server.py @@ -4,7 +4,7 @@ import re import threading -from openerp import models, api, tools +from odoo import models, api, tools class IrMailServer(models.Model): diff --git a/mail_tracking/models/mail_mail.py b/mail_tracking/models/mail_mail.py index b33a1c5e..58df1385 100644 --- a/mail_tracking/models/mail_mail.py +++ b/mail_tracking/models/mail_mail.py @@ -6,7 +6,7 @@ import time from datetime import datetime from email.utils import COMMASPACE -from openerp import models, api, fields +from odoo import models, fields class MailMail(models.Model): @@ -18,7 +18,7 @@ class MailMail(models.Model): email_to_list = email.get('email_to', []) email_to = COMMASPACE.join(email_to_list) return { - 'name': email.get('subject', False), + 'name': self.subject, 'timestamp': '%.6f' % ts, 'time': fields.Datetime.to_string(dt), 'mail_id': self.id, @@ -28,7 +28,6 @@ class MailMail(models.Model): 'sender': self.email_from, } - @api.multi def send_get_email_dict(self, partner=None): email = super(MailMail, self).send_get_email_dict(partner=partner) vals = self._tracking_email_prepare(partner, email) diff --git a/mail_tracking/models/mail_message.py b/mail_tracking/models/mail_message.py index fc6562bf..83f39571 100644 --- a/mail_tracking/models/mail_message.py +++ b/mail_tracking/models/mail_message.py @@ -2,7 +2,7 @@ # © 2016 Antonio Espinosa - # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import models, api +from odoo import models, api class MailMessage(models.Model): @@ -31,7 +31,6 @@ class MailMessage(models.Model): status = tracking_status_map.get(tracking_email_status, 'unknown') return status - @api.multi def tracking_status(self): res = {} for message in self: diff --git a/mail_tracking/models/mail_tracking_email.py b/mail_tracking/models/mail_tracking_email.py index 7e2202bd..9dea7b16 100644 --- a/mail_tracking/models/mail_tracking_email.py +++ b/mail_tracking/models/mail_tracking_email.py @@ -8,8 +8,8 @@ import time import re from datetime import datetime -from openerp import models, api, fields, tools -import openerp.addons.decimal_precision as dp +from odoo import models, api, fields, tools +import odoo.addons.decimal_precision as dp _logger = logging.getLogger(__name__) @@ -26,7 +26,7 @@ class MailTrackingEmail(models.Model): name = fields.Char(string="Subject", readonly=True, index=True) display_name = fields.Char( string="Display name", readonly=True, store=True, - compute="_compute_display_name") + compute="_compute_tracking_display_name") timestamp = fields.Float( string='UTC timestamp', readonly=True, digits=dp.get_precision('MailTracking Timestamp')) @@ -120,7 +120,6 @@ class MailTrackingEmail(models.Model): else: return [(5, False, False)] - @api.multi def _email_score_tracking_filter(self): """Default email score filter for tracking emails""" # Consider only last 10 tracking emails @@ -133,7 +132,6 @@ class MailTrackingEmail(models.Model): ]) return trackings.email_score() - @api.multi def email_score(self): """Default email score algorimth""" score = 50.0 @@ -153,7 +151,6 @@ class MailTrackingEmail(models.Model): score = 100.0 return score - @api.multi @api.depends('recipient') def _compute_recipient_address(self): for email in self: @@ -163,16 +160,14 @@ class MailTrackingEmail(models.Model): else: email.recipient_address = email.recipient - @api.multi @api.depends('name', 'recipient') - def _compute_display_name(self): + def _compute_tracking_display_name(self): for email in self: parts = [email.name or ''] if email.recipient: parts.append(email.recipient) email.display_name = ' - '.join(parts) - @api.multi @api.depends('time') def _compute_date(self): for email in self: @@ -202,7 +197,6 @@ class MailTrackingEmail(models.Model): 'tracking_email_id': self.id, }) - @api.multi def smtp_error(self, mail_server, smtp_server, exception): self.sudo().write({ 'error_smtp_server': tools.ustr(smtp_server), @@ -212,7 +206,6 @@ class MailTrackingEmail(models.Model): }) return True - @api.multi def tracking_img_add(self, email): self.ensure_one() tracking_url = self._get_mail_tracking_img() @@ -240,7 +233,6 @@ class MailTrackingEmail(models.Model): }) return True - @api.multi def _tracking_sent_prepare(self, mail_server, smtp_server, message, message_id): self.ensure_one() @@ -286,7 +278,6 @@ class MailTrackingEmail(models.Model): concurrent_event_ids = m_event.search(domain) return concurrent_event_ids - @api.multi def event_create(self, event_type, metadata): event_ids = self.env['mail.tracking.event'] for tracking_email in self: diff --git a/mail_tracking/models/mail_tracking_event.py b/mail_tracking/models/mail_tracking_event.py index 728f88c0..c3fb9861 100644 --- a/mail_tracking/models/mail_tracking_event.py +++ b/mail_tracking/models/mail_tracking_event.py @@ -5,8 +5,8 @@ import time from datetime import datetime -from openerp import models, api, fields -import openerp.addons.decimal_precision as dp +from odoo import models, api, fields +import odoo.addons.decimal_precision as dp class MailTrackingEvent(models.Model): @@ -51,7 +51,6 @@ class MailTrackingEvent(models.Model): error_description = fields.Char(string='Error description', readonly=True) error_details = fields.Text(string='Error details', readonly=True) - @api.multi @api.depends('time') def _compute_date(self): for email in self: diff --git a/mail_tracking/models/res_partner.py b/mail_tracking/models/res_partner.py index 908f1190..793f7702 100644 --- a/mail_tracking/models/res_partner.py +++ b/mail_tracking/models/res_partner.py @@ -2,7 +2,7 @@ # © 2016 Antonio Espinosa - # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import models, api, fields +from odoo import models, api, fields class ResPartner(models.Model): @@ -17,7 +17,6 @@ class ResPartner(models.Model): email_score = fields.Float( string="Email score", readonly=True, default=50.0) - @api.multi def email_score_calculate(self): # This is not a compute method because is causing a inter-block # in mail_tracking_email PostgreSQL table @@ -28,15 +27,14 @@ class ResPartner(models.Model): for partner in self: partner.email_score = partner.tracking_email_ids.email_score() - @api.one @api.depends('tracking_email_ids') def _compute_tracking_emails_count(self): - self.tracking_emails_count = self.env['mail.tracking.email'].\ - search_count([ - ('recipient_address', '=ilike', self.email) - ]) + for partner in self: + partner.tracking_emails_count = self.env['mail.tracking.email'].\ + search_count([ + ('recipient_address', '=ilike', partner.email) + ]) - @api.multi def write(self, vals): email = vals.get('email') if email is not None: diff --git a/mail_tracking/static/src/js/mail_tracking.js b/mail_tracking/static/src/js/mail_tracking.js index 473b9f7a..7e1daa5e 100644 --- a/mail_tracking/static/src/js/mail_tracking.js +++ b/mail_tracking/static/src/js/mail_tracking.js @@ -4,7 +4,6 @@ odoo.define('mail_tracking.partner_tracking', function(require){ "use strict"; -var $ = require('$'); var core = require('web.core'); var session = require('web.session'); var Model = require('web.Model'); @@ -26,7 +25,7 @@ chat_manager.make_message = function(data) { ChatThread.include({ on_tracking_partner_click: function (event) { - var partner_id = $(event.currentTarget).data('partner'); + var partner_id = this.$el.find(event.currentTarget).data('partner'); var state = { 'model': 'res.partner', 'id': partner_id, diff --git a/mail_tracking/tests/test_mail_tracking.py b/mail_tracking/tests/test_mail_tracking.py index 5862db90..4a1777b8 100644 --- a/mail_tracking/tests/test_mail_tracking.py +++ b/mail_tracking/tests/test_mail_tracking.py @@ -5,12 +5,12 @@ import mock import base64 import time -from openerp.tests.common import TransactionCase +from odoo.tests.common import TransactionCase from ..controllers.main import MailTrackingController, BLANK -mock_request = 'openerp.http.request' -mock_send_email = ('openerp.addons.base.ir.ir_mail_server.' - 'ir_mail_server.send_email') +mock_request = 'odoo.http.request' +mock_send_email = ('odoo.addons.base.ir.ir_mail_server.' + 'IrMailServer.send_email') class FakeUserAgent(object): @@ -50,7 +50,7 @@ class TestMailTracking(TransactionCase): 'subject': 'Message test', 'author_id': self.sender.id, 'email_from': self.sender.email, - 'type': 'comment', + 'message_type': 'comment', 'model': 'res.partner', 'res_id': self.recipient.id, 'partner_ids': [(4, self.recipient.id)], @@ -65,9 +65,7 @@ class TestMailTracking(TransactionCase): self.assertTrue(tracking_email) self.assertEqual(tracking_email.state, 'sent') # message_dict read by web interface - message_dict = message.message_read() - # First item in threads is message content - message_dict = message_dict['threads'][0][0] + message_dict = message.message_format()[0] self.assertTrue(len(message_dict['partner_ids']) > 0) # First partner is recipient partner_id = message_dict['partner_ids'][0][0] diff --git a/mail_tracking/views/assets.xml b/mail_tracking/views/assets.xml index e4cac0d7..685721a9 100644 --- a/mail_tracking/views/assets.xml +++ b/mail_tracking/views/assets.xml @@ -2,16 +2,14 @@ - -