[IMP] pre-commit run -a

This commit is contained in:
Jairo Llopis 2021-01-26 14:06:17 +00:00 committed by Jasmin Solanki
parent 29afd15f6d
commit c64663944b
13 changed files with 616 additions and 436 deletions

View File

@ -8,7 +8,9 @@
<field name="res_id" ref="base.partner_demo" />
<field name="message_type">comment</field>
<field name="subtype_id" ref="mail.mt_comment" />
<field name="email_cc">acc@testmail.com,wood.corner26@example.com,toni.rhodes11@example.com</field>
<field
name="email_cc"
>acc@testmail.com,wood.corner26@example.com,toni.rhodes11@example.com</field>
<field name="mail_tracking_needs_action">1</field>
<field name="body"><![CDATA[<p>This is a message with CC</p>]]></field>
<field name="email_from">wood.corner26@example.com</field>

View File

@ -4,10 +4,15 @@
<odoo>
<record model="ir.rule" id="mail_tracking_email_portal_public_rule">
<field name="name">mail_tracking_email: portal/public: read access on my email trackings</field>
<field
name="name"
>mail_tracking_email: portal/public: read access on my email trackings</field>
<field name="model_id" ref="model_mail_tracking_email" />
<field name="domain_force">[('partner_id', '=', user.partner_id.id)]</field>
<field name="groups" eval="[(4, ref('base.group_portal')), (4, ref('base.group_public'))]"/>
<field
name="groups"
eval="[(4, ref('base.group_portal')), (4, ref('base.group_public'))]"
/>
<field name="perm_create" eval="False" />
<field name="perm_unlink" eval="False" />
<field name="perm_write" eval="False" />

View File

@ -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);

View File

@ -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,26 +9,22 @@ 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.
@ -41,7 +37,6 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
});
Message.include({
/**
* Overrides to store information from server
*
@ -59,7 +54,7 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
* @override
*/
isFailed: function() {
return _.contains(this._threadIDs, 'mailbox_failed');
return _.contains(this._threadIDs, "mailbox_failed");
},
/**
@ -69,9 +64,9 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
*/
setFailed: function(failed) {
if (failed) {
this._addThread('mailbox_failed');
this._addThread("mailbox_failed");
} else {
this.removeThread('mailbox_failed');
this.removeThread("mailbox_failed");
}
},
@ -87,14 +82,13 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
});
MailManagerNotif.include({
/**
* Overrides to handle changes in the 'mail_tracking_needs_action' flag
*
* @override
*/
_handlePartnerNotification: function(data) {
if (data.type === 'toggle_tracking_status') {
if (data.type === "toggle_tracking_status") {
this._handleChangeTrackingNeedsActionNotification(data);
} else {
// Workaround to avoid call '_handlePartnerChannelNotification'
@ -115,7 +109,7 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
*/
_handleChangeTrackingNeedsActionNotification: function(data) {
var self = this;
var failed = this.getMailbox('failed');
var failed = this.getMailbox("failed");
_.each(data.message_ids, function(messageID) {
var message = _.find(self._messages, function(msg) {
return msg.getID() === messageID;
@ -123,14 +117,13 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
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",
}),
/**
@ -160,7 +153,7 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
* @returns {Object}
*/
_sidebarQWebParams: function() {
var failed = this.call('mail_service', 'getMailbox', 'failed');
var failed = this.call("mail_service", "getMailbox", "failed");
return {
activeThreadID: this._thread ? this._thread.getID() : undefined,
failedCounter: failed.getMailboxCounter(),
@ -177,10 +170,12 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
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;
},
@ -192,9 +187,9 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
*/
_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())
);
},
/**
@ -205,9 +200,12 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
_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")
);
},
/**
@ -218,10 +216,10 @@ 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');
this.$btn_set_all_reviewed.toggleClass(
"d-none d-md-none",
thread.getID() !== "mailbox_failed"
);
return this._super.apply(this, arguments);
},
@ -234,17 +232,15 @@ 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);
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",
});
}
}
@ -258,15 +254,13 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
_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 () {
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)
self._threadWidget
.removeMessageAndRender(message.getID(), self._thread, options)
.then(function() {
self._updateButtonStatus(
!self._thread.hasMessages(), type);
self._updateButtonStatus(!self._thread.hasMessages(), type);
});
});
} else {
@ -285,7 +279,7 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
*/
_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;
@ -301,8 +295,11 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
*/
_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
@ -314,8 +311,8 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
*/
_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,
},
@ -331,10 +328,10 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
*/
_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,
});
@ -351,7 +348,6 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
});
MailManager.include({
/**
* Add the 'failed' mailbox
*
@ -360,7 +356,7 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
_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') {
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
@ -398,14 +393,13 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
* reviewed on the server
*/
setAllMessagesAsReviewed: function() {
if (this._id === 'mailbox_failed' && this.getMailboxCounter() > 0) {
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();
},
});
});

View File

@ -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
*
@ -29,12 +28,14 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
return $.when([]);
}
var context = widget.record && widget.record.getContext();
return widget._rpc({
model: 'mail.message',
method: 'get_failed_messages',
return widget
._rpc({
model: "mail.message",
method: "get_failed_messages",
args: [ids],
context: context || widget.getSession().user_context,
}).then(function (messages) {
})
.then(function(messages) {
// Convert date to moment
_.each(messages, function(msg) {
msg.date = moment(time.auto_str_to_date(msg.date));
@ -45,7 +46,6 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
}
BasicModel.include({
/**
* Fetch data for the 'mail_failed_message' field widget in form views.
*
@ -55,19 +55,21 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
* @returns {Array}
*/
_fetchSpecialFailedMessages: function(record, fieldName) {
var localID = record._changes && fieldName in record._changes
? record._changes[fieldName] : record.data[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
@ -86,8 +88,7 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
*/
start: function() {
this._super.apply(this, arguments);
this.call(
'bus_service', 'onNotification', this, this._onNotification);
this.call("bus_service", "onNotification", this, this._onNotification);
},
/**
@ -110,9 +111,12 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
*/
_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();
}
@ -137,7 +141,7 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
* @param {Array} fieldsToReload
*/
_reload: function(fieldsToReload) {
this.trigger_up('reload_mail_fields', fieldsToReload);
this.trigger_up("reload_mail_fields", fieldsToReload);
},
/**
@ -149,8 +153,8 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
*/
_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(),
});
@ -169,9 +173,9 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
var self = this;
_.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});
}
@ -188,8 +192,8 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
*/
_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,
},
@ -204,17 +208,17 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
*/
_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.
@ -245,7 +249,6 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
});
Chatter.include({
/**
* Overrides to initialize 'mail_failed_message' widget.
*
@ -256,7 +259,11 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
// 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
);
}
},
@ -271,7 +278,8 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
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")
);
}
});
},
@ -283,7 +291,7 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
*/
_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,7 +304,6 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
});
MailThread.include({
/**
* Show 'retry' & 'Set as reviewed' buttons in the Chatter
*
@ -312,5 +319,4 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
});
return FailedMessage;
});

View File

@ -2,19 +2,18 @@
Copyright 2018 David Vidal - <david.vidal@tecnativa.com>
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.
*
@ -106,8 +105,8 @@ odoo.define('mail_tracking.partner_tracking', function (require) {
toggleTrackingStatus: function() {
return this._rpc({
model: 'mail.message',
method: 'toggle_tracking_status',
model: "mail.message",
method: "toggle_tracking_status",
args: [[this.id]],
});
},
@ -115,46 +114,45 @@ 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');
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');
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);

View File

@ -3,10 +3,18 @@
<t t-extend="mail.widget.Thread.Message">
<t t-jquery="span[t-attf-class=o_thread_icons]" t-operation="append">
<a t-if="message.isFailed() &amp;&amp; options.displayRetryButton" class="btn btn-link o_thread_icon btn-default text-muted btn-sm o_failed_message_reviewed o_activity_link mr8" t-att-data-message-id="message.getID()">
<a
t-if="message.isFailed() &amp;&amp; options.displayRetryButton"
class="btn btn-link o_thread_icon btn-default text-muted btn-sm o_failed_message_reviewed o_activity_link mr8"
t-att-data-message-id="message.getID()"
>
<i class="fa fa-check" /> Set as Reviewed
</a>
<a t-if="message.isFailed() &amp;&amp; options.displayReviewedButton" class="btn btn-link o_thread_icon btn-default text-muted btn-sm o_failed_message_retry" t-att-data-message-id="message.getID()">
<a
t-if="message.isFailed() &amp;&amp; options.displayReviewedButton"
class="btn btn-link o_thread_icon btn-default text-muted btn-sm o_failed_message_retry"
t-att-data-message-id="message.getID()"
>
<i class="fa fa-retweet" /> Retry
</a>
</t>

View File

@ -2,14 +2,18 @@
<templates>
<t t-name="mail_tracking.SidebarFailedCounter">
<span t-attf-class="o_mail_sidebar_failed badge badge-pill #{(counter ? '' : 'd-none')}">
<span
t-attf-class="o_mail_sidebar_failed badge badge-pill #{(counter ? '' : 'd-none')}"
>
<t t-esc="counter" />
</span>
</t>
<t t-name="mail_tracking.SidebarFailed">
<div t-attf-class="o_mail_discuss_title_main o_mail_discuss_item #{(activeThreadID === 'mailbox_failed') ? 'o_active': ''}"
data-thread-id="mailbox_failed">
<div
t-attf-class="o_mail_discuss_title_main o_mail_discuss_item #{(activeThreadID === 'mailbox_failed') ? 'o_active': ''}"
data-thread-id="mailbox_failed"
>
<span class="o_thread_name"><i class="fa fa-exclamation mr8" />Failed</span>
<t t-set="counter" t-value="failedCounter" />
<t t-call="mail_tracking.SidebarFailedCounter" />
@ -19,7 +23,9 @@
<t t-extend="mail.widget.Thread.Empty">
<t t-jquery="t:last-child" t-operation="after">
<t t-if="thread.getID() === 'mailbox_failed'">
<div class="o_thread_title">Congratulations, you don't have any failed messages</div>
<div
class="o_thread_title"
>Congratulations, you don't have any failed messages</div>
<div>Failed messages appear here.</div>
</t>
</t>
@ -27,7 +33,11 @@
<t t-extend="mail.discuss.ControlButtons">
<t t-jquery="div" t-operation="append">
<button type="button" class="btn btn-secondary o_mail_discuss_button_set_all_reviewed d-none d-md-none d-md-inline-block" title="Mark all as reviewed">Set all as reviewed</button>
<button
type="button"
class="btn btn-secondary o_mail_discuss_button_set_all_reviewed d-none d-md-none d-md-inline-block"
title="Mark all as reviewed"
>Set all as reviewed</button>
</t>
</t>

View File

@ -7,47 +7,50 @@
<t t-name="mail.tracking.status">
<t t-if="tracking['isCc']">
<span class="mail_tracking_cc">
<i class="fa fa-cc"></i>
<i class="fa fa-cc" />
</span>
</t>
<t t-elif="!tracking['isCc'] &amp;&amp; !tracking['partner_id']">
<span class="mail_anon_recipient">
<i class="fa fa-low-vision"></i>
<i class="fa fa-low-vision" />
</span>
</t>
<t t-elif="tracking['status'] === 'unknown'">
<span class="mail_tracking_unknown">
<i class="fa fa-ban"></i>
<i class="fa fa-ban" />
</span>
</t>
<t t-elif="tracking['status'] === 'waiting'">
<span class="mail_tracking_waiting mail_tracking_pointer">
<i class="fa fa-clock-o"></i>
<i class="fa fa-clock-o" />
</span>
</t>
<t t-elif="tracking['status'] === 'error'">
<span class="mail_tracking_error mail_tracking_pointer">
<i t-if="tracking['error_type'] === 'no_recipient'" class="fa fa-user-times"></i>
<i t-else="" class="fa fa-remove"></i>
<i
t-if="tracking['error_type'] === 'no_recipient'"
class="fa fa-user-times"
/>
<i t-else="" class="fa fa-remove" />
</span>
</t>
<t t-elif="tracking['status'] === 'sent'">
<span class="mail_tracking_sent mail_tracking_pointer">
<i class="fa fa-check"></i>
<i class="fa fa-check" />
</span>
</t>
<t t-elif="tracking['status'] === 'delivered'">
<span class="fa-stack mail_tracking_delivered mail_tracking_pointer">
<i class="fa fa-check fa-stack-1x" style="margin-left:1px"></i>
<i class="fa fa-check fa-inverse fa-stack-1x" style="margin-left:-2px;"></i>
<i class="fa fa-check fa-stack-1x" style="margin-left:-3px"></i>
<i class="fa fa-check fa-stack-1x" style="margin-left:1px" />
<i class="fa fa-check fa-inverse fa-stack-1x" style="margin-left:-2px;" />
<i class="fa fa-check fa-stack-1x" style="margin-left:-3px" />
</span>
</t>
<t t-elif="tracking['status'] === 'opened'">
<span class="fa-stack mail_tracking_opened mail_tracking_pointer">
<i class="fa fa-check fa-stack-1x" style="margin-left:1px"></i>
<i class="fa fa-check fa-inverse fa-stack-1x" style="margin-left:-2px;"></i>
<i class="fa fa-check fa-stack-1x" style="margin-left:-3px"></i>
<i class="fa fa-check fa-stack-1x" style="margin-left:1px" />
<i class="fa fa-check fa-inverse fa-stack-1x" style="margin-left:-2px;" />
<i class="fa fa-check fa-stack-1x" style="margin-left:-3px" />
</span>
</t>
</t>
@ -62,20 +65,34 @@
-
</t>
<t t-if="tracking['partner_id']">
<a t-attf-class="o_mail_action_tracking_partner #{tracking['isCc'] ? 'o_mail_cc' : ''}"
<a
t-attf-class="o_mail_action_tracking_partner #{tracking['isCc'] ? 'o_mail_cc' : ''}"
t-att-data-partner="tracking['partner_id']"
t-attf-href="#model=res.partner&amp;id=#{tracking['partner_id']}">
t-attf-href="#model=res.partner&amp;id=#{tracking['partner_id']}"
>
<t t-esc="tracking['recipient']" />
</a>
</t>
<t t-else="">
<span t-attf-class="#{tracking['isCc'] ? 'o_mail_cc' : ''}"><t t-esc="tracking['recipient']"/></span>
<span t-attf-class="#{tracking['isCc'] ? 'o_mail_cc' : ''}"><t
t-esc="tracking['recipient']"
/></span>
</t>
<t t-if="tracking['status'] === 'error' &amp;&amp; tracking['error_type'] === 'no_recipient'" t-set="title_status" t-value="tracking['error_description']" />
<t t-else="" t-set="title_status" t-value="tracking['status_human']" />
<span class="mail_tracking o_mail_action_tracking_status"
<t
t-if="tracking['status'] === 'error' &amp;&amp; tracking['error_type'] === 'no_recipient'"
t-set="title_status"
t-value="tracking['error_description']"
/>
<t
t-else=""
t-set="title_status"
t-value="tracking['status_human']"
/>
<span
class="mail_tracking o_mail_action_tracking_status"
t-att-data-tracking="tracking['tracking_id']"
t-att-title="title_status">
t-att-title="title_status"
>
<t t-call="mail.tracking.status" />
</span>
</t>

View File

@ -2,20 +2,32 @@
<!-- Copyright 2016 Antonio Espinosa - <antonio.espinosa@tecnativa.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<odoo>
<template id="assets_backend"
<template
id="assets_backend"
name="mail_tracking assets"
inherit_id="web.assets_backend">
inherit_id="web.assets_backend"
>
<xpath expr="." position="inside">
<link rel="stylesheet"
href="/mail_tracking/static/src/css/mail_tracking.scss"/>
<link rel="stylesheet"
href="/mail_tracking/static/src/css/failed_message.scss"/>
<script type="text/javascript"
src="/mail_tracking/static/src/js/mail_tracking.js"/>
<script type="text/javascript"
src="/mail_tracking/static/src/js/failed_message/discuss.js"/>
<script type="text/javascript"
src="/mail_tracking/static/src/js/failed_message/thread.js"/>
<link
rel="stylesheet"
href="/mail_tracking/static/src/css/mail_tracking.scss"
/>
<link
rel="stylesheet"
href="/mail_tracking/static/src/css/failed_message.scss"
/>
<script
type="text/javascript"
src="/mail_tracking/static/src/js/mail_tracking.js"
/>
<script
type="text/javascript"
src="/mail_tracking/static/src/js/failed_message/discuss.js"
/>
<script
type="text/javascript"
src="/mail_tracking/static/src/js/failed_message/thread.js"
/>
</xpath>
</template>
</odoo>

View File

@ -34,18 +34,22 @@
<field name="bounce_description" />
</group>
<group attrs="{'invisible': [('error_type', '=', False)]}">
<field name="error_smtp_server"
attrs="{'invisible': [('error_smtp_server', '=', False)]}"/>
<field
name="error_smtp_server"
attrs="{'invisible': [('error_smtp_server', '=', False)]}"
/>
<field name="error_type" />
<field name="error_description" />
</group>
<label for="tracking_event_ids" />
<div>
<field name="tracking_event_ids">
<tree string="Tracking events"
<tree
string="Tracking events"
decoration-muted="event_type == 'deferral'"
decoration-danger="event_type in ('hard_bounce', 'soft_bounce', 'spam', 'reject')"
decoration-info="event_type in ('unsub', 'click', 'open')">
decoration-info="event_type in ('unsub', 'click', 'open')"
>
<field name="time" />
<field name="event_type" />
<field name="ip" />
@ -65,11 +69,16 @@
<field name="name">mail.tracking.email.tree</field>
<field name="model">mail.tracking.email</field>
<field name="arch" type="xml">
<tree string="MailTracking emails" create="false" edit="false" delete="false"
<tree
string="MailTracking emails"
create="false"
edit="false"
delete="false"
decoration-muted="state in (False, 'deferred')"
decoration-success="state == 'opened'"
decoration-danger="state in ('rejected', 'spam', 'bounced', 'soft-bounced', 'error')"
decoration-info="state == 'unsub'">
decoration-info="state == 'unsub'"
>
<field name="time" />
<field name="date" invisible="1" />
<field name="name" />
@ -85,25 +94,63 @@
<field name="model">mail.tracking.email</field>
<field name="arch" type="xml">
<search string="MailTracking email search">
<field name="display_name" string="Email"
filter_domain="['|', ('sender', 'ilike', self), ('recipient', 'ilike', self)]"/>
<field
name="display_name"
string="Email"
filter_domain="['|', ('sender', 'ilike', self), ('recipient', 'ilike', self)]"
/>
<field name="sender" string="Sender" />
<field name="recipient" string="Recipient" />
<field name="name" string="Subject" />
<field name="time" string="Time" />
<field name="date" string="Date" />
<filter name="sent" string="Sent" domain="[('state', 'in', ('sent',))]" />
<filter name="deferred" string="Deferred" domain="[('state', '=', 'deferred')]"/>
<filter name="delivered" string="Delivered" domain="[('state', 'in', ('delivered', 'opened'))]"/>
<filter name="unsub" string="Unsubscribed" domain="[('state', '=', 'unsub')]"/>
<filter name="exception" string="Failed"
domain="[('state', 'in', ('error', 'rejected', 'spam', 'bounced', 'soft-bounced'))]"/>
<filter
name="deferred"
string="Deferred"
domain="[('state', '=', 'deferred')]"
/>
<filter
name="delivered"
string="Delivered"
domain="[('state', 'in', ('delivered', 'opened'))]"
/>
<filter
name="unsub"
string="Unsubscribed"
domain="[('state', '=', 'unsub')]"
/>
<filter
name="exception"
string="Failed"
domain="[('state', 'in', ('error', 'rejected', 'spam', 'bounced', 'soft-bounced'))]"
/>
<separator />
<group expand="0" string="Group By">
<filter string="State" name="group_by_state" domain="[]" context="{'group_by': 'state'}"/>
<filter string="Subject" name="group_by_subject" domain="[]" context="{'group_by': 'name'}"/>
<filter string="Sender" name="group_by_sender" domain="[]" context="{'group_by': 'sender'}"/>
<filter string="Month" name="group_by_month" domain="[]" context="{'group_by': 'date'}"/>
<filter
string="State"
name="group_by_state"
domain="[]"
context="{'group_by': 'state'}"
/>
<filter
string="Subject"
name="group_by_subject"
domain="[]"
context="{'group_by': 'name'}"
/>
<filter
string="Sender"
name="group_by_sender"
domain="[]"
context="{'group_by': 'sender'}"
/>
<filter
string="Month"
name="group_by_month"
domain="[]"
context="{'group_by': 'date'}"
/>
</group>
</search>
</field>
@ -118,8 +165,11 @@
</record>
<!-- Add menu entry in Settings/Email -->
<menuitem name="Tracking emails" id="menu_mail_tracking_email"
<menuitem
name="Tracking emails"
id="menu_mail_tracking_email"
parent="base.menu_email"
action="action_view_mail_tracking_email"/>
action="action_view_mail_tracking_email"
/>
</odoo>

View File

@ -24,10 +24,14 @@
<group attrs="{'invisible': [('event_type', 'not in', ('sent',))]}">
<field name="smtp_server" />
</group>
<group attrs="{'invisible': [('event_type', 'not in', ('open', 'click'))]}">
<group
attrs="{'invisible': [('event_type', 'not in', ('open', 'click'))]}"
>
<field name="url" />
</group>
<group attrs="{'invisible': [('event_type', 'not in', ('open', 'click'))]}">
<group
attrs="{'invisible': [('event_type', 'not in', ('open', 'click'))]}"
>
<group>
<field name="mobile" />
<field name="ip" />
@ -40,8 +44,10 @@
<field name="os_family" />
</group>
</group>
<group string="Error"
attrs="{'invisible': [('error_type', '=', False)]}">
<group
string="Error"
attrs="{'invisible': [('error_type', '=', False)]}"
>
<field name="error_type" />
<field name="error_description" />
<field name="error_details" />
@ -55,15 +61,23 @@
<field name="name">mail.tracking.event.tree</field>
<field name="model">mail.tracking.event</field>
<field name="arch" type="xml">
<tree string="MailTracking events" create="false" edit="false" delete="false"
<tree
string="MailTracking events"
create="false"
edit="false"
delete="false"
decoration-muted="event_type == 'deferred'"
decoration-danger="event_type in ('hard_bounce', 'soft_bounce', 'spam', 'reject')"
decoration-info="event_type in ('unsub', 'click', 'open')">
decoration-info="event_type in ('unsub', 'click', 'open')"
>
<field name="time" />
<field name="tracking_email_id" />
<field name="recipient" />
<field name="event_type" />
<field name="error_details" invisible="not context.get('event_error_filter', False)"/>
<field
name="error_details"
invisible="not context.get('event_error_filter', False)"
/>
<field name="date" invisible="1" />
<field name="ip" />
<field name="url" />
@ -79,32 +93,88 @@
<field name="model">mail.tracking.event</field>
<field name="arch" type="xml">
<search string="MailTracking event search">
<field name="tracking_email_id" string="Message"
filter_domain="[('tracking_email_id', 'ilike', self)]"/>
<field
name="tracking_email_id"
string="Message"
filter_domain="[('tracking_email_id', 'ilike', self)]"
/>
<field name="recipient" string="Recipient" />
<field name="time" string="Time" />
<field name="date" string="Date" />
<field name="ip" string="IP" />
<field name="url" string="URL" />
<filter name="sent" string="Sent" domain="[('event_type', '=', 'sent')]" />
<filter name="delivered" string="Delivered" domain="[('event_type', '=', 'delivered')]"/>
<filter name="click" string="Click" domain="[('event_type', '=', 'click')]"/>
<filter
name="delivered"
string="Delivered"
domain="[('event_type', '=', 'delivered')]"
/>
<filter
name="click"
string="Click"
domain="[('event_type', '=', 'click')]"
/>
<filter name="open" string="Open" domain="[('event_type', '=', 'open')]" />
<filter name="unsub" string="Unsubscribe" domain="[('event_type', '=', 'unsub')]"/>
<filter name="bounce" string="Bounce"
domain="[('event_type', 'in', ('hard_bounce', 'soft_bounce'))]"/>
<filter name="exception" string="Failed"
<filter
name="unsub"
string="Unsubscribe"
domain="[('event_type', '=', 'unsub')]"
/>
<filter
name="bounce"
string="Bounce"
domain="[('event_type', 'in', ('hard_bounce', 'soft_bounce'))]"
/>
<filter
name="exception"
string="Failed"
domain="[('event_type', 'in', ('reject', 'spam'))]"
context="{'event_error_filter': True}"/>
context="{'event_error_filter': True}"
/>
<separator />
<group expand="0" string="Group By">
<filter string="Type" name="group_by_type" domain="[]" context="{'group_by': 'event_type'}"/>
<filter string="Message" name="group_by_message" domain="[]" context="{'group_by': 'tracking_email_id'}"/>
<filter string="OS" name="group_by_os" domain="[('os_family', '!=', False)]" context="{'group_by': 'os_family'}"/>
<filter string="User agent" name="group_by_user_agent" domain="[('ua_family', '!=', False)]" context="{'group_by': 'ua_family'}"/>
<filter string="User agent type" name="group_by_user_agent_type" domain="[('ua_type', '!=', False)]" context="{'group_by': 'ua_type'}"/>
<filter string="Country" name="group_by_country" domain="[('user_country_id', '!=', False)]" context="{'group_by': 'user_country_id'}"/>
<filter string="Month" name="group_by_date" domain="[]" context="{'group_by': 'date'}"/>
<filter
string="Type"
name="group_by_type"
domain="[]"
context="{'group_by': 'event_type'}"
/>
<filter
string="Message"
name="group_by_message"
domain="[]"
context="{'group_by': 'tracking_email_id'}"
/>
<filter
string="OS"
name="group_by_os"
domain="[('os_family', '!=', False)]"
context="{'group_by': 'os_family'}"
/>
<filter
string="User agent"
name="group_by_user_agent"
domain="[('ua_family', '!=', False)]"
context="{'group_by': 'ua_family'}"
/>
<filter
string="User agent type"
name="group_by_user_agent_type"
domain="[('ua_type', '!=', False)]"
context="{'group_by': 'ua_type'}"
/>
<filter
string="Country"
name="group_by_country"
domain="[('user_country_id', '!=', False)]"
context="{'group_by': 'user_country_id'}"
/>
<filter
string="Month"
name="group_by_date"
domain="[]"
context="{'group_by': 'date'}"
/>
</group>
</search>
</field>
@ -118,9 +188,12 @@
</record>
<!-- Add menu entry in Settings/Email -->
<menuitem name="Tracking events" id="menu_mail_tracking_event"
<menuitem
name="Tracking events"
id="menu_mail_tracking_event"
parent="base.menu_email"
action="action_view_mail_tracking_event"/>
action="action_view_mail_tracking_event"
/>
</odoo>