From c64663944b008d69e2c828b6942cc45afbb125a0 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Tue, 26 Jan 2021 14:06:17 +0000 Subject: [PATCH] [IMP] pre-commit run -a --- mail_tracking/demo/demo.xml | 14 +- .../security/mail_tracking_email_security.xml | 19 +- .../static/src/css/failed_message.scss | 33 +-- .../static/src/js/failed_message/discuss.js | 206 +++++++++--------- .../static/src/js/failed_message/thread.js | 150 +++++++------ mail_tracking/static/src/js/mail_tracking.js | 90 ++++---- .../static/src/xml/failed_message/common.xml | 18 +- .../static/src/xml/failed_message/discuss.xml | 30 ++- .../static/src/xml/mail_tracking.xml | 69 +++--- mail_tracking/views/assets.xml | 40 ++-- mail_tracking/views/mail_message_view.xml | 4 +- .../views/mail_tracking_email_view.xml | 174 +++++++++------ .../views/mail_tracking_event_view.xml | 205 +++++++++++------ 13 files changed, 616 insertions(+), 436 deletions(-) diff --git a/mail_tracking/demo/demo.xml b/mail_tracking/demo/demo.xml index e90d45d..e26ae1d 100644 --- a/mail_tracking/demo/demo.xml +++ b/mail_tracking/demo/demo.xml @@ -1,4 +1,4 @@ - + @@ -8,7 +8,9 @@ comment - acc@testmail.com,wood.corner26@example.com,toni.rhodes11@example.com + acc@testmail.com,wood.corner26@example.com,toni.rhodes11@example.com 1 This is a message with CC

]]>
wood.corner26@example.com @@ -24,7 +26,7 @@ demo@yourcompany.example.com wood.corner26@example.com sent - + @@ -48,7 +50,7 @@ demo@yourcompany.example.com wood.corner26@example.com error - + @@ -72,7 +74,7 @@ demo@yourcompany.example.com jackson.group82@example.com error - + @@ -96,7 +98,7 @@ demo@yourcompany.example.com admin@example.com error - +
diff --git a/mail_tracking/security/mail_tracking_email_security.xml b/mail_tracking/security/mail_tracking_email_security.xml index 306851f..0793f84 100644 --- a/mail_tracking/security/mail_tracking_email_security.xml +++ b/mail_tracking/security/mail_tracking_email_security.xml @@ -1,16 +1,21 @@ - + - mail_tracking_email: portal/public: read access on my email trackings - + mail_tracking_email: portal/public: read access on my email trackings + [('partner_id', '=', user.partner_id.id)] - - - - + + + + diff --git a/mail_tracking/static/src/css/failed_message.scss b/mail_tracking/static/src/css/failed_message.scss index e9216e0..7bd1be3 100644 --- a/mail_tracking/static/src/css/failed_message.scss +++ b/mail_tracking/static/src/css/failed_message.scss @@ -31,7 +31,7 @@ } i.fa-caret-down:before { - content: '\f0da'; + content: "\f0da"; } } } @@ -52,7 +52,7 @@ } .o_thread_typing_notification_free_space { - flex-grow: 1, + flex-grow: 1; } .o_thread_typing_notification_bar { @@ -60,7 +60,7 @@ background-color: rgba($white, 0.75); padding: 5px; text-align: center; - color: gray('600'); + color: gray("600"); &.o_thread_order_asc { @include o-position-sticky($bottom: 0px); @@ -83,7 +83,7 @@ margin-top: 0px; margin-bottom: 15px; } - border-bottom: 1px solid gray('400'); + border-bottom: 1px solid gray("400"); text-align: center; .o_thread_date { @@ -116,8 +116,8 @@ margin-bottom: 0px; &.o_mail_not_discussion { - background-color: rgba(gray('300'), 0.5); - border-bottom: 1px solid gray('400'); + background-color: rgba(gray("300"), 0.5); + border-bottom: 1px solid gray("400"); } .o_thread_message_sidebar { @@ -155,7 +155,8 @@ } } - &:hover, &.o_thread_selected_message { + &:hover, + &.o_thread_selected_message { .o_thread_message_side_date { opacity: $o-mail-thread-side-date-opacity; } @@ -182,8 +183,6 @@ text-align: justify; } - - .o_mail_subject { font-style: italic; } @@ -193,7 +192,8 @@ color: gray; } - [summary~=o_mail_notification] { // name conflicts with channel notifications, but is odoo notification buttons to hide in chatter if present + [summary~="o_mail_notification"] { + // name conflicts with channel notifications, but is odoo notification buttons to hide in chatter if present display: none; } @@ -224,7 +224,10 @@ } } - .o_thread_message_star, .o_thread_message_needaction, .o_thread_message_reply, .o_thread_message_email { + .o_thread_message_star, + .o_thread_message_needaction, + .o_thread_message_reply, + .o_thread_message_email { padding: 4px; } @@ -232,14 +235,16 @@ &.o_thread_message_email_ready { color: grey; } - &.o_thread_message_email_exception, &.o_thread_message_email_bounce { + &.o_thread_message_email_exception, + &.o_thread_message_email_bounce { color: red; opacity: 1; cursor: pointer; } } - .o_attachments_list, .o_attachments_previews { + .o_attachments_list, + .o_attachments_previews { &:last-child { margin-bottom: $grid-gutter-width; } @@ -299,7 +304,7 @@ .o_activity_info { vertical-align: baseline; padding: 4px 6px; - background: theme-color('light'); + background: theme-color("light"); border-radius: 2px 2px 0 0; @include o-hover-opacity(1, 1); diff --git a/mail_tracking/static/src/js/failed_message/discuss.js b/mail_tracking/static/src/js/failed_message/discuss.js index 6deb131..adf4214 100644 --- a/mail_tracking/static/src/js/failed_message/discuss.js +++ b/mail_tracking/static/src/js/failed_message/discuss.js @@ -1,6 +1,6 @@ /* Copyright 2019 Alexandre Díaz License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). */ -odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { +odoo.define("mail_tracking.FailedMessageDiscuss", function(require) { "use strict"; // To be considered: @@ -9,45 +9,40 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { // - A mailbox is a type of thread that is displayed on top of // the discuss menu, has a counter, etc... - var MailManagerNotif = require('mail.Manager.Notification'); - var AbstractMessage = require('mail.model.AbstractMessage'); - var Message = require('mail.model.Message'); - var Discuss = require('mail.Discuss'); - var MailManager = require('mail.Manager'); - var Mailbox = require('mail.model.Mailbox'); - var core = require('web.core'); - var session = require('web.session'); + var MailManagerNotif = require("mail.Manager.Notification"); + var AbstractMessage = require("mail.model.AbstractMessage"); + var Message = require("mail.model.Message"); + var Discuss = require("mail.Discuss"); + var MailManager = require("mail.Manager"); + var Mailbox = require("mail.model.Mailbox"); + var core = require("web.core"); + var session = require("web.session"); var QWeb = core.qweb; var _t = core._t; /* The states to consider a message as failed message */ - var FAILED_STATES = [ - 'error', 'rejected', 'spam', 'bounced', 'soft-bounced', - ]; - + var FAILED_STATES = ["error", "rejected", "spam", "bounced", "soft-bounced"]; AbstractMessage.include({ - /** * Abstract declaration to know if a message is included in the * failed mailbox. By default it should be false. * * @returns {Boolean} */ - isFailed: function () { + isFailed: function() { return false; }, }); Message.include({ - /** * Overrides to store information from server * * @override */ - init: function (parent, data) { + init: function(parent, data) { this._isFailedMessage = data.is_failed_message; return this._super.apply(this, arguments); }, @@ -58,8 +53,8 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * * @override */ - isFailed: function () { - return _.contains(this._threadIDs, 'mailbox_failed'); + isFailed: function() { + return _.contains(this._threadIDs, "mailbox_failed"); }, /** @@ -67,11 +62,11 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * * @param {Boolean} failed */ - setFailed: function (failed) { + setFailed: function(failed) { if (failed) { - this._addThread('mailbox_failed'); + this._addThread("mailbox_failed"); } else { - this.removeThread('mailbox_failed'); + this.removeThread("mailbox_failed"); } }, @@ -80,21 +75,20 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * * @override */ - _processMailboxes: function () { + _processMailboxes: function() { this.setFailed(this._isFailedMessage); return this._super.apply(this, arguments); }, }); MailManagerNotif.include({ - /** * Overrides to handle changes in the 'mail_tracking_needs_action' flag * * @override */ - _handlePartnerNotification: function (data) { - if (data.type === 'toggle_tracking_status') { + _handlePartnerNotification: function(data) { + if (data.type === "toggle_tracking_status") { this._handleChangeTrackingNeedsActionNotification(data); } else { // Workaround to avoid call '_handlePartnerChannelNotification' @@ -113,24 +107,23 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * @private * @param {Object} data */ - _handleChangeTrackingNeedsActionNotification: function (data) { + _handleChangeTrackingNeedsActionNotification: function(data) { var self = this; - var failed = this.getMailbox('failed'); - _.each(data.message_ids, function (messageID) { - var message = _.find(self._messages, function (msg) { + var failed = this.getMailbox("failed"); + _.each(data.message_ids, function(messageID) { + var message = _.find(self._messages, function(msg) { return msg.getID() === messageID; }); if (message) { message.setFailed(data.needs_actions); if (message.isFailed() === false) { - self._removeMessageFromThread( - 'mailbox_failed', message); + self._removeMessageFromThread("mailbox_failed", message); } else { self._addMessageToThreads(message, []); - var channelFailed = self.getMailbox('failed'); + var channelFailed = self.getMailbox("failed"); channelFailed.invalidateCaches(); } - self._mailBus.trigger('update_message', message, data.type); + self._mailBus.trigger("update_message", message, data.type); } }); @@ -143,14 +136,14 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { } // Trigger event to refresh threads - this._mailBus.trigger('update_failed', failed.getMailboxCounter()); + this._mailBus.trigger("update_failed", failed.getMailboxCounter()); }, }); Discuss.include({ events: _.extend({}, Discuss.prototype.events, { - 'click .o_failed_message_retry': '_onRetryFailedMessage', - 'click .o_failed_message_reviewed': '_onMarkFailedMessageReviewed', + "click .o_failed_message_retry": "_onRetryFailedMessage", + "click .o_failed_message_reviewed": "_onMarkFailedMessageReviewed", }), /** @@ -159,8 +152,8 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * @private * @returns {Object} */ - _sidebarQWebParams: function () { - var failed = this.call('mail_service', 'getMailbox', 'failed'); + _sidebarQWebParams: function() { + var failed = this.call("mail_service", "getMailbox", "failed"); return { activeThreadID: this._thread ? this._thread.getID() : undefined, failedCounter: failed.getMailboxCounter(), @@ -173,14 +166,16 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * * @override */ - _renderSidebar: function () { + _renderSidebar: function() { var $sidebar = this._super.apply(this, arguments); // Because Odoo implementation isn't designed to be inherited // properly, we inject 'failed' button using jQuery. - var $failed_item = $(QWeb.render('mail_tracking.SidebarFailed', - this._sidebarQWebParams())); + var $failed_item = $( + QWeb.render("mail_tracking.SidebarFailed", this._sidebarQWebParams()) + ); $failed_item.insertAfter( - $sidebar.find(".o_mail_discuss_title_main").filter(":last")); + $sidebar.find(".o_mail_discuss_title_main").filter(":last") + ); return $sidebar; }, @@ -190,11 +185,11 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * * @override */ - _renderSidebarMailboxes: function () { + _renderSidebarMailboxes: function() { this._super.apply(this, arguments); - this.$('.o_mail_discuss_sidebar_mailboxes').append( - QWeb.render('mail_tracking.SidebarFailed', - this._sidebarQWebParams())); + this.$(".o_mail_discuss_sidebar_mailboxes").append( + QWeb.render("mail_tracking.SidebarFailed", this._sidebarQWebParams()) + ); }, /** @@ -202,12 +197,15 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * * @override */ - _renderButtons: function () { + _renderButtons: function() { this._super.apply(this, arguments); this.$btn_set_all_reviewed = this.$buttons.find( - '.o_mail_discuss_button_set_all_reviewed'); - this.$btn_set_all_reviewed - .on('click', $.proxy(this, "_onSetAllAsReviewedClicked")); + ".o_mail_discuss_button_set_all_reviewed" + ); + this.$btn_set_all_reviewed.on( + "click", + $.proxy(this, "_onSetAllAsReviewedClicked") + ); }, /** @@ -217,11 +215,11 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * * @override */ - _updateControlPanelButtons: function (thread) { - this.$btn_set_all_reviewed - .toggleClass( - 'd-none d-md-none', - thread.getID() !== 'mailbox_failed'); + _updateControlPanelButtons: function(thread) { + this.$btn_set_all_reviewed.toggleClass( + "d-none d-md-none", + thread.getID() !== "mailbox_failed" + ); return this._super.apply(this, arguments); }, @@ -233,18 +231,16 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * * @override */ - _updateButtonStatus: function (disabled, type) { - if (this._thread.getID() === 'mailbox_failed') { - this.$btn_set_all_reviewed - .toggleClass('disabled', disabled); + _updateButtonStatus: function(disabled, type) { + if (this._thread.getID() === "mailbox_failed") { + this.$btn_set_all_reviewed.toggleClass("disabled", disabled); // Display Rainbowman when all failed messages are reviewed // through 'TOGGLE TRACKING STATUS' or marking last failed // message as reviewed - if (disabled && type === 'toggle_tracking_status') { - this.trigger_up('show_effect', { - message: _t( - "Congratulations, your failed mailbox is empty"), - type: 'rainbow_man', + if (disabled && type === "toggle_tracking_status") { + this.trigger_up("show_effect", { + message: _t("Congratulations, your failed mailbox is empty"), + type: "rainbow_man", }); } } @@ -255,20 +251,18 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * * @override */ - _onMessageUpdated: function (message, type) { + _onMessageUpdated: function(message, type) { var self = this; var currentThreadID = this._thread.getID(); - if (currentThreadID === 'mailbox_failed' && !message.isFailed()) { - this._thread.fetchMessages(this.domain) - .then(function () { - var options = self._getThreadRenderingOptions(); - self._threadWidget.removeMessageAndRender( - message.getID(), self._thread, options) - .then(function () { - self._updateButtonStatus( - !self._thread.hasMessages(), type); - }); - }); + if (currentThreadID === "mailbox_failed" && !message.isFailed()) { + this._thread.fetchMessages(this.domain).then(function() { + var options = self._getThreadRenderingOptions(); + self._threadWidget + .removeMessageAndRender(message.getID(), self._thread, options) + .then(function() { + self._updateButtonStatus(!self._thread.hasMessages(), type); + }); + }); } else { // Workaround to avoid calling '_fetchAndRenderThread' and // refetching thread messages because these messages are @@ -283,9 +277,9 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * * @override */ - _getThreadRenderingOptions: function () { + _getThreadRenderingOptions: function() { var values = this._super.apply(this, arguments); - if (this._thread.getID() === 'mailbox_failed') { + if (this._thread.getID() === "mailbox_failed") { values.displayEmailIcons = true; values.displayReplyIcons = false; values.displayRetryButton = true; @@ -299,10 +293,13 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * * @override */ - _startListening: function () { + _startListening: function() { this._super.apply(this, arguments); - this.call('mail_service', 'getMailBus') - .on('update_failed', this, this._throttledUpdateThreads); + this.call("mail_service", "getMailBus").on( + "update_failed", + this, + this._throttledUpdateThreads + ); }, // Handlers @@ -312,10 +309,10 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * @private * @param {Event} event */ - _onRetryFailedMessage: function (event) { + _onRetryFailedMessage: function(event) { event.preventDefault(); - var messageID = $(event.currentTarget).data('message-id'); - this.do_action('mail.mail_resend_message_action', { + var messageID = $(event.currentTarget).data("message-id"); + this.do_action("mail.mail_resend_message_action", { additional_context: { mail_message_to_resend: messageID, }, @@ -329,12 +326,12 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * @param {Event} event * @returns {Promise} */ - _onMarkFailedMessageReviewed: function (event) { + _onMarkFailedMessageReviewed: function(event) { event.preventDefault(); - var messageID = $(event.currentTarget).data('message-id'); + var messageID = $(event.currentTarget).data("message-id"); return this._rpc({ - model: 'mail.message', - method: 'set_need_action_done', + model: "mail.message", + method: "set_need_action_done", args: [[messageID]], context: this.getSession().user_context, }); @@ -345,22 +342,21 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * * @private */ - _onSetAllAsReviewedClicked: function () { + _onSetAllAsReviewedClicked: function() { this._thread.setAllMessagesAsReviewed(); }, }); MailManager.include({ - /** * Add the 'failed' mailbox * * @override */ - _updateMailboxesFromServer: function (data) { + _updateMailboxesFromServer: function(data) { this._super.apply(this, arguments); this._addMailbox({ - id: 'failed', + id: "failed", name: _t("Failed"), mailboxCounter: data.failed_counter || 0, }); @@ -368,20 +364,19 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { }); Mailbox.include({ - /** * Overrides to add domain for 'failed' mailbox thread * * @override */ - _getThreadDomain: function () { - if (this._id === 'mailbox_failed') { + _getThreadDomain: function() { + if (this._id === "mailbox_failed") { return [ - ['mail_tracking_ids.state', 'in', FAILED_STATES], - ['mail_tracking_needs_action', '=', true], - '|', - ['partner_ids', 'in', [session.partner_id]], - ['author_id', '=', session.partner_id], + ["mail_tracking_ids.state", "in", FAILED_STATES], + ["mail_tracking_needs_action", "=", true], + "|", + ["partner_ids", "in", [session.partner_id]], + ["author_id", "=", session.partner_id], ]; } // Workaround to avoid throw 'Missing domain' exception. Call _super @@ -397,15 +392,14 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) { * @returns {$.Promise} resolved when all messages have been marked as * reviewed on the server */ - setAllMessagesAsReviewed: function () { - if (this._id === 'mailbox_failed' && this.getMailboxCounter() > 0) { + setAllMessagesAsReviewed: function() { + if (this._id === "mailbox_failed" && this.getMailboxCounter() > 0) { return this._rpc({ - model: 'mail.message', - method: 'set_all_as_reviewed', + model: "mail.message", + method: "set_all_as_reviewed", }); } return $.when(); }, }); - }); diff --git a/mail_tracking/static/src/js/failed_message/thread.js b/mail_tracking/static/src/js/failed_message/thread.js index 652b881..bceacc8 100644 --- a/mail_tracking/static/src/js/failed_message/thread.js +++ b/mail_tracking/static/src/js/failed_message/thread.js @@ -1,21 +1,20 @@ /* Copyright 2019 Alexandre Díaz License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). */ -odoo.define('mail_tracking.FailedMessageThread', function (require) { +odoo.define("mail_tracking.FailedMessageThread", function(require) { "use strict"; - var AbstractField = require('web.AbstractField'); - var BasicModel = require('web.BasicModel'); - var BasicView = require('web.BasicView'); - var Chatter = require('mail.Chatter'); - var MailThread = require('mail.widget.Thread'); - var utils = require('mail.utils'); - var core = require('web.core'); - var field_registry = require('web.field_registry'); - var time = require('web.time'); + var AbstractField = require("web.AbstractField"); + var BasicModel = require("web.BasicModel"); + var BasicView = require("web.BasicView"); + var Chatter = require("mail.Chatter"); + var MailThread = require("mail.widget.Thread"); + var utils = require("mail.utils"); + var core = require("web.core"); + var field_registry = require("web.field_registry"); + var time = require("web.time"); var QWeb = core.qweb; - /** * Helper method to fetch failed messages * @@ -24,28 +23,29 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) { * @param {Array} ids * @returns {Array} */ - function _readMessages (widget, ids) { + function _readMessages(widget, ids) { if (!ids.length) { return $.when([]); } var context = widget.record && widget.record.getContext(); - return widget._rpc({ - model: 'mail.message', - method: 'get_failed_messages', - args: [ids], - context: context || widget.getSession().user_context, - }).then(function (messages) { - // Convert date to moment - _.each(messages, function (msg) { - msg.date = moment(time.auto_str_to_date(msg.date)); - msg.hour = utils.timeFromNow(msg.date); + return widget + ._rpc({ + model: "mail.message", + method: "get_failed_messages", + args: [ids], + context: context || widget.getSession().user_context, + }) + .then(function(messages) { + // Convert date to moment + _.each(messages, function(msg) { + msg.date = moment(time.auto_str_to_date(msg.date)); + msg.hour = utils.timeFromNow(msg.date); + }); + return messages; }); - return messages; - }); } BasicModel.include({ - /** * Fetch data for the 'mail_failed_message' field widget in form views. * @@ -54,27 +54,29 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) { * @param {String} fieldName * @returns {Array} */ - _fetchSpecialFailedMessages: function (record, fieldName) { - var localID = record._changes && fieldName in record._changes - ? record._changes[fieldName] : record.data[fieldName]; + _fetchSpecialFailedMessages: function(record, fieldName) { + var localID = + record._changes && fieldName in record._changes + ? record._changes[fieldName] + : record.data[fieldName]; return _readMessages(this, this.localData[localID].res_ids); }, }); var FailedMessage = AbstractField.extend({ - className: 'o_mail_failed_message', + className: "o_mail_failed_message", events: { - 'click .o_failed_message_retry': '_onRetryFailedMessage', - 'click .o_failed_message_reviewed': '_onMarkFailedMessageReviewed', + "click .o_failed_message_retry": "_onRetryFailedMessage", + "click .o_failed_message_reviewed": "_onMarkFailedMessageReviewed", }, - specialData: '_fetchSpecialFailedMessages', + specialData: "_fetchSpecialFailedMessages", /** * Overrides to reference failed messages in a easy way * * @override */ - init: function () { + init: function() { this._super.apply(this, arguments); this.failed_messages = this.record.specialData[this.name] || []; }, @@ -84,10 +86,9 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) { * * @override */ - start: function () { + start: function() { this._super.apply(this, arguments); - this.call( - 'bus_service', 'onNotification', this, this._onNotification); + this.call("bus_service", "onNotification", this, this._onNotification); }, /** @@ -96,7 +97,7 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) { * @private * @returns {Object} */ - _failedItemsQWebParams: function () { + _failedItemsQWebParams: function() { return { failed_messages: this.failed_messages, nbFailedMessages: this.failed_messages.length, @@ -108,11 +109,14 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) { /** * @private */ - _render: function () { + _render: function() { if (this.failed_messages.length) { - this.$el.html(QWeb.render( - 'mail_tracking.failed_message_items', - this._failedItemsQWebParams())); + this.$el.html( + QWeb.render( + "mail_tracking.failed_message_items", + this._failedItemsQWebParams() + ) + ); } else { this.$el.empty(); } @@ -124,7 +128,7 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) { * @private * @param {Object} record */ - _reset: function (record) { + _reset: function(record) { this._super.apply(this, arguments); this.failed_messages = this.record.specialData[this.name] || []; this.res_id = record.res_id; @@ -136,8 +140,8 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) { * @private * @param {Array} fieldsToReload */ - _reload: function (fieldsToReload) { - this.trigger_up('reload_mail_fields', fieldsToReload); + _reload: function(fieldsToReload) { + this.trigger_up("reload_mail_fields", fieldsToReload); }, /** @@ -147,10 +151,10 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) { * @param {Int} id * @returns {Promise} */ - _markFailedMessageReviewed: function (id) { + _markFailedMessageReviewed: function(id) { return this._rpc({ - model: 'mail.message', - method: 'set_need_action_done', + model: "mail.message", + method: "set_need_action_done", args: [[id]], context: this.record.getContext(), }); @@ -165,13 +169,13 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) { * @private * @param {Array} notifs */ - _onNotification: function (notifs) { + _onNotification: function(notifs) { var self = this; - _.each(notifs, function (notif) { + _.each(notifs, function(notif) { var model = notif[0][1]; - if (model === 'res.partner') { + if (model === "res.partner") { var data = notif[1]; - if (data.type === 'toggle_tracking_status') { + if (data.type === "toggle_tracking_status") { // Reload 'mail_failed_message' widget self._reload({failed_message: true}); } @@ -186,10 +190,10 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) { * @private * @param {Event} event */ - _onRetryFailedMessage: function (event) { + _onRetryFailedMessage: function(event) { event.preventDefault(); - var messageID = $(event.currentTarget).data('message-id'); - this.do_action('mail.mail_resend_message_action', { + var messageID = $(event.currentTarget).data("message-id"); + this.do_action("mail.mail_resend_message_action", { additional_context: { mail_message_to_resend: messageID, }, @@ -202,26 +206,26 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) { * @private * @param {Event} event */ - _onMarkFailedMessageReviewed: function (event) { + _onMarkFailedMessageReviewed: function(event) { event.preventDefault(); - var messageID = $(event.currentTarget).data('message-id'); + var messageID = $(event.currentTarget).data("message-id"); this._markFailedMessageReviewed(messageID).then( - $.proxy(this, "_reload", {failed_message: true})); + $.proxy(this, "_reload", {failed_message: true}) + ); }, }); - field_registry.add('mail_failed_message', FailedMessage); + field_registry.add("mail_failed_message", FailedMessage); - var mailWidgets = ['mail_failed_message']; + var mailWidgets = ["mail_failed_message"]; BasicView.include({ - /** * Overrides to add 'mail_failed_message' widget as "mail widget" used * in Chatter. * * @override */ - init: function () { + init: function() { this._super.apply(this, arguments); var fieldsInfo = this.fieldsInfo[this.viewType]; for (var fieldName in fieldsInfo) { @@ -245,18 +249,21 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) { }); Chatter.include({ - /** * Overrides to initialize 'mail_failed_message' widget. * * @override */ - init: function (parent, record, mailFields, options) { + init: function(parent, record, mailFields, options) { this._super.apply(this, arguments); // Initialize mail_failed_message widget if (mailFields.mail_failed_message) { this.fields.failed_message = new FailedMessage( - this, mailFields.mail_failed_message, record, options); + this, + mailFields.mail_failed_message, + record, + options + ); } }, @@ -266,12 +273,13 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) { * @private * @returns {Promise} */ - _render: function () { + _render: function() { var self = this; - return this._super.apply(this, arguments).then(function () { + return this._super.apply(this, arguments).then(function() { if (self.fields.failed_message) { self.fields.failed_message.$el.insertBefore( - self.$el.find('.o_mail_thread')); + self.$el.find(".o_mail_thread") + ); } }); }, @@ -281,9 +289,9 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) { * * @override */ - _onReloadMailFields: function (event) { + _onReloadMailFields: function(event) { if (this.fields.failed_message && event.data.failed_message) { - this.trigger_up('reload', { + this.trigger_up("reload", { fieldNames: [this.fields.failed_message.name], keepChanges: true, }); @@ -296,13 +304,12 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) { }); MailThread.include({ - /** * Show 'retry' & 'Set as reviewed' buttons in the Chatter * * @override */ - init: function () { + init: function() { this._super.apply(this, arguments); this._enabledOptions.displayRetryButton = true; this._enabledOptions.displayReviewedButton = true; @@ -312,5 +319,4 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) { }); return FailedMessage; - }); diff --git a/mail_tracking/static/src/js/mail_tracking.js b/mail_tracking/static/src/js/mail_tracking.js index 34148a7..2e14eab 100644 --- a/mail_tracking/static/src/js/mail_tracking.js +++ b/mail_tracking/static/src/js/mail_tracking.js @@ -2,25 +2,24 @@ Copyright 2018 David Vidal - License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). */ -odoo.define('mail_tracking.partner_tracking', function (require) { +odoo.define("mail_tracking.partner_tracking", function(require) { "use strict"; - var core = require('web.core'); - var ActionManager = require('web.ActionManager'); - var AbstractMessage = require('mail.model.AbstractMessage'); - var Message = require('mail.model.Message'); - var ThreadWidget = require('mail.widget.Thread'); + var core = require("web.core"); + var ActionManager = require("web.ActionManager"); + var AbstractMessage = require("mail.model.AbstractMessage"); + var Message = require("mail.model.Message"); + var ThreadWidget = require("mail.widget.Thread"); var _t = core._t; AbstractMessage.include({ - /** * Messages do not have any PartnerTrackings. * * @returns {Boolean} */ - hasPartnerTrackings: function () { + hasPartnerTrackings: function() { return false; }, @@ -29,13 +28,13 @@ odoo.define('mail_tracking.partner_tracking', function (require) { * * @returns {Boolean} */ - hasEmailCc: function () { + hasEmailCc: function() { return false; }, }); Message.include({ - init: function (parent, data) { + init: function(parent, data) { this._super.apply(this, arguments); this._partnerTrackings = data.partner_trackings || []; this._emailCc = data.email_cc || []; @@ -48,7 +47,7 @@ odoo.define('mail_tracking.partner_tracking', function (require) { * @override * @returns {Boolean} */ - hasPartnerTrackings: function () { + hasPartnerTrackings: function() { return _.some(this._partnerTrackings); }, @@ -57,7 +56,7 @@ odoo.define('mail_tracking.partner_tracking', function (require) { * * @returns {Boolean} */ - hasEmailCc: function () { + hasEmailCc: function() { return _.some(this._emailCc); }, @@ -68,7 +67,7 @@ odoo.define('mail_tracking.partner_tracking', function (require) { * @override * @returns {Object[]} */ - getPartnerTrackings: function () { + getPartnerTrackings: function() { if (!this.hasPartnerTrackings()) { return []; } @@ -81,7 +80,7 @@ odoo.define('mail_tracking.partner_tracking', function (require) { * * @returns {Array} */ - getEmailCc: function () { + getEmailCc: function() { if (!this.hasEmailCc()) { return []; } @@ -95,19 +94,19 @@ odoo.define('mail_tracking.partner_tracking', function (require) { * @param {String} email * @returns {Boolean} */ - isEmailCc: function (email) { + isEmailCc: function(email) { if (!this.hasEmailCc()) { return false; } - return _.some(this._emailCc, function (item) { + return _.some(this._emailCc, function(item) { return item[0] === email; }); }, - toggleTrackingStatus: function () { + toggleTrackingStatus: function() { return this._rpc({ - model: 'mail.message', - method: 'toggle_tracking_status', + model: "mail.message", + method: "toggle_tracking_status", args: [[this.id]], }); }, @@ -115,53 +114,52 @@ odoo.define('mail_tracking.partner_tracking', function (require) { 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', + "click .o_mail_action_tracking_partner": "on_tracking_partner_click", + "click .o_mail_action_tracking_status": "on_tracking_status_click", }), - on_tracking_partner_click: function (event) { - var partner_id = this.$el.find(event.currentTarget).data('partner'); + on_tracking_partner_click: function(event) { + var partner_id = this.$el.find(event.currentTarget).data("partner"); var state = { - 'model': 'res.partner', - 'id': partner_id, - 'title': _t("Tracking partner"), + model: "res.partner", + id: partner_id, + title: _t("Tracking partner"), }; event.preventDefault(); this.action_manager.do_push_state(state); var action = { - type:'ir.actions.act_window', - view_type: 'form', - view_mode: 'form', - res_model: 'res.partner', - views: [[false, 'form']], - target: 'current', + type: "ir.actions.act_window", + view_type: "form", + view_mode: "form", + res_model: "res.partner", + views: [[false, "form"]], + target: "current", res_id: partner_id, }; this.do_action(action); }, - on_tracking_status_click: function (event) { - var tracking_email_id = $(event.currentTarget).data('tracking'); + on_tracking_status_click: function(event) { + var tracking_email_id = $(event.currentTarget).data("tracking"); var state = { - 'model': 'mail.tracking.email', - 'id': tracking_email_id, - 'title': _t("Message tracking"), + model: "mail.tracking.email", + id: tracking_email_id, + title: _t("Message tracking"), }; event.preventDefault(); this.action_manager.do_push_state(state); var action = { - type:'ir.actions.act_window', - view_type: 'form', - view_mode: 'form', - res_model: 'mail.tracking.email', - views: [[false, 'form']], - target: 'new', + type: "ir.actions.act_window", + view_type: "form", + view_mode: "form", + res_model: "mail.tracking.email", + views: [[false, "form"]], + target: "new", res_id: tracking_email_id, }; this.do_action(action); }, - init: function () { + init: function() { this._super.apply(this, arguments); - this.action_manager = this.findAncestor(function (ancestor) { + this.action_manager = this.findAncestor(function(ancestor) { return ancestor instanceof ActionManager; }); }, diff --git a/mail_tracking/static/src/xml/failed_message/common.xml b/mail_tracking/static/src/xml/failed_message/common.xml index 0961617..5aeeb81 100644 --- a/mail_tracking/static/src/xml/failed_message/common.xml +++ b/mail_tracking/static/src/xml/failed_message/common.xml @@ -1,13 +1,21 @@ - + - - Set as Reviewed + + Set as Reviewed - - Retry + + Retry diff --git a/mail_tracking/static/src/xml/failed_message/discuss.xml b/mail_tracking/static/src/xml/failed_message/discuss.xml index 8f56388..3248de4 100644 --- a/mail_tracking/static/src/xml/failed_message/discuss.xml +++ b/mail_tracking/static/src/xml/failed_message/discuss.xml @@ -1,25 +1,31 @@ - + - - + + -
- Failed - - +
+ Failed + +
-
Congratulations, you don't have any failed messages
+
Congratulations, you don't have any failed messages
Failed messages appear here.
@@ -27,7 +33,11 @@ - + diff --git a/mail_tracking/static/src/xml/mail_tracking.xml b/mail_tracking/static/src/xml/mail_tracking.xml index 37e4d2e..ebfaf46 100644 --- a/mail_tracking/static/src/xml/mail_tracking.xml +++ b/mail_tracking/static/src/xml/mail_tracking.xml @@ -1,4 +1,4 @@ - + @@ -7,54 +7,57 @@ - + - + - + - + - - + + - + - - - + + + - - - + + + - +

To: @@ -62,21 +65,35 @@ - - - + + - + - - - - + + + +

diff --git a/mail_tracking/views/assets.xml b/mail_tracking/views/assets.xml index 5853ae1..9fa8b7a 100644 --- a/mail_tracking/views/assets.xml +++ b/mail_tracking/views/assets.xml @@ -1,21 +1,33 @@ - + -