[FIX] mail_tracking: Refresh thread widget when sets a message as reviewed
Previous this commit, failed messages widget data wasn't updated properly when you set as reviewed/retry the last message displayed. This commit resolve the problem and improves the "set as reviewed" action to avoid multi-user inconsistencies (don't toggle the value).
This commit is contained in:
parent
67aba949d8
commit
5f9e8ff95e
@ -92,7 +92,7 @@ msgstr ""
|
|||||||
|
|
||||||
#. module: mail_tracking
|
#. module: mail_tracking
|
||||||
#. openerp-web
|
#. openerp-web
|
||||||
#: code:addons/mail_tracking/static/src/js/failed_message/discuss.js:231
|
#: code:addons/mail_tracking/static/src/js/failed_message/discuss.js:232
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Congratulations, your failed mailbox is empty"
|
msgid "Congratulations, your failed mailbox is empty"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -232,7 +232,7 @@ msgstr ""
|
|||||||
|
|
||||||
#. module: mail_tracking
|
#. module: mail_tracking
|
||||||
#. openerp-web
|
#. openerp-web
|
||||||
#: code:addons/mail_tracking/static/src/js/failed_message/discuss.js:350
|
#: code:addons/mail_tracking/static/src/js/failed_message/discuss.js:351
|
||||||
#: code:addons/mail_tracking/static/src/xml/failed_message/discuss.xml:13
|
#: code:addons/mail_tracking/static/src/xml/failed_message/discuss.xml:13
|
||||||
#: code:addons/mail_tracking/static/src/xml/failed_message/thread.xml:21
|
#: code:addons/mail_tracking/static/src/xml/failed_message/thread.xml:21
|
||||||
#: model_terms:ir.ui.view,arch_db:mail_tracking.view_mail_tracking_email_search
|
#: model_terms:ir.ui.view,arch_db:mail_tracking.view_mail_tracking_email_search
|
||||||
|
@ -203,18 +203,17 @@ class MailMessage(models.Model):
|
|||||||
for msg in self.sorted('date', reverse=True)]
|
for msg in self.sorted('date', reverse=True)]
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def toggle_tracking_status(self):
|
def set_need_action_done(self):
|
||||||
"""Toggle message tracking action.
|
"""Set message tracking action as done
|
||||||
|
|
||||||
This will mark them to be (or not) ignored in the tracking issues
|
This will mark them to be ignored in the tracking issues filter.
|
||||||
filter.
|
|
||||||
"""
|
"""
|
||||||
self.check_access_rule('read')
|
self.check_access_rule('read')
|
||||||
self.mail_tracking_needs_action = not self.mail_tracking_needs_action
|
self.write({'mail_tracking_needs_action': False})
|
||||||
notification = {
|
notification = {
|
||||||
'type': 'toggle_tracking_status',
|
'type': 'toggle_tracking_status',
|
||||||
'message_ids': [self.id],
|
'message_ids': self.ids,
|
||||||
'needs_actions': self.mail_tracking_needs_action
|
'needs_actions': False
|
||||||
}
|
}
|
||||||
self.env['bus.bus'].sendone(
|
self.env['bus.bus'].sendone(
|
||||||
(self._cr.dbname, 'res.partner', self.env.user.partner_id.id),
|
(self._cr.dbname, 'res.partner', self.env.user.partner_id.id),
|
||||||
|
@ -42,23 +42,13 @@ class MailResendMessage(models.TransientModel):
|
|||||||
tracking_ids.write({'state': False})
|
tracking_ids.write({'state': False})
|
||||||
# Send bus notifications to update Discuss and
|
# Send bus notifications to update Discuss and
|
||||||
# mail_failed_messages widget
|
# mail_failed_messages widget
|
||||||
notifications = [
|
notification = {
|
||||||
[
|
'type': 'toggle_tracking_status',
|
||||||
(self._cr.dbname, 'res.partner',
|
'message_ids': [self.mail_message_id.id],
|
||||||
self.env.user.partner_id.id),
|
'needs_actions': False
|
||||||
{
|
}
|
||||||
'type': 'update_failed_messages',
|
self.env['bus.bus'].sendone(
|
||||||
}
|
(self._cr.dbname, 'res.partner',
|
||||||
],
|
self.env.user.partner_id.id),
|
||||||
[
|
notification)
|
||||||
(self._cr.dbname, 'res.partner',
|
|
||||||
self.env.user.partner_id.id),
|
|
||||||
{
|
|
||||||
'type': 'toggle_tracking_status',
|
|
||||||
'message_ids': [self.mail_message_id.id],
|
|
||||||
'needs_actions': False,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
self.env['bus.bus'].sendmany(notifications)
|
|
||||||
super().resend_mail_action()
|
super().resend_mail_action()
|
||||||
|
@ -95,7 +95,7 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
|
|||||||
*/
|
*/
|
||||||
_handlePartnerNotification: function (data) {
|
_handlePartnerNotification: function (data) {
|
||||||
if (data.type === 'toggle_tracking_status') {
|
if (data.type === 'toggle_tracking_status') {
|
||||||
this._handlePartnerToggleFailedNotification(data);
|
this._handleChangeTrackingNeedsActionNotification(data);
|
||||||
} else {
|
} else {
|
||||||
// Workaround to avoid call '_handlePartnerChannelNotification'
|
// Workaround to avoid call '_handlePartnerChannelNotification'
|
||||||
// because this is related with the failed mailbox, not a
|
// because this is related with the failed mailbox, not a
|
||||||
@ -106,13 +106,14 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method updates messages in the failed mailbox when the flag
|
* This method updates messages in the failed mailbox when the flag
|
||||||
* 'mail_tracking_needs_action' is toggled. This can remove/add
|
* 'mail_tracking_needs_action' was changed to False. This can
|
||||||
* the message from/to failed mailbox and update mailbox counter.
|
* remove/add the message from/to failed mailbox and update mailbox
|
||||||
|
* counter.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} data
|
* @param {Object} data
|
||||||
*/
|
*/
|
||||||
_handlePartnerToggleFailedNotification: function (data) {
|
_handleChangeTrackingNeedsActionNotification: function (data) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var failed = this.getMailbox('failed');
|
var failed = this.getMailbox('failed');
|
||||||
_.each(data.message_ids, function (messageID) {
|
_.each(data.message_ids, function (messageID) {
|
||||||
@ -320,7 +321,7 @@ odoo.define('mail_tracking.FailedMessageDiscuss', function (require) {
|
|||||||
var messageID = $(event.currentTarget).data('message-id');
|
var messageID = $(event.currentTarget).data('message-id');
|
||||||
return this._rpc({
|
return this._rpc({
|
||||||
model: 'mail.message',
|
model: 'mail.message',
|
||||||
method: 'toggle_tracking_status',
|
method: 'set_need_action_done',
|
||||||
args: [[messageID]],
|
args: [[messageID]],
|
||||||
context: this.getSession().user_context,
|
context: this.getSession().user_context,
|
||||||
});
|
});
|
||||||
|
@ -26,7 +26,7 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
|
|||||||
*/
|
*/
|
||||||
function _readMessages (widget, ids) {
|
function _readMessages (widget, ids) {
|
||||||
if (!ids.length) {
|
if (!ids.length) {
|
||||||
return $.when();
|
return $.when([]);
|
||||||
}
|
}
|
||||||
var context = widget.record && widget.record.getContext();
|
var context = widget.record && widget.record.getContext();
|
||||||
return widget._rpc({
|
return widget._rpc({
|
||||||
@ -150,7 +150,7 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
|
|||||||
_markFailedMessageReviewed: function (id) {
|
_markFailedMessageReviewed: function (id) {
|
||||||
return this._rpc({
|
return this._rpc({
|
||||||
model: 'mail.message',
|
model: 'mail.message',
|
||||||
method: 'toggle_tracking_status',
|
method: 'set_need_action_done',
|
||||||
args: [[id]],
|
args: [[id]],
|
||||||
context: this.record.getContext(),
|
context: this.record.getContext(),
|
||||||
});
|
});
|
||||||
@ -171,7 +171,7 @@ odoo.define('mail_tracking.FailedMessageThread', function (require) {
|
|||||||
var model = notif[0][1];
|
var model = notif[0][1];
|
||||||
if (model === 'res.partner') {
|
if (model === 'res.partner') {
|
||||||
var data = notif[1];
|
var data = notif[1];
|
||||||
if (data.type === 'update_failed_messages') {
|
if (data.type === 'toggle_tracking_status') {
|
||||||
// Reload 'mail_failed_message' widget
|
// Reload 'mail_failed_message' widget
|
||||||
self._reload({failed_message: true});
|
self._reload({failed_message: true});
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ class TestMailTracking(TransactionCase):
|
|||||||
self.assertTrue(messages)
|
self.assertTrue(messages)
|
||||||
self.assertTrue(messages_failed)
|
self.assertTrue(messages_failed)
|
||||||
self.assertTrue(len(messages) > len(messages_failed))
|
self.assertTrue(len(messages) > len(messages_failed))
|
||||||
tracking.mail_message_id.toggle_tracking_status()
|
tracking.mail_message_id.set_need_action_done()
|
||||||
self.assertFalse(tracking.mail_message_id.mail_tracking_needs_action)
|
self.assertFalse(tracking.mail_message_id.mail_tracking_needs_action)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
MailMessageObj.get_failed_count() < failed_count)
|
MailMessageObj.get_failed_count() < failed_count)
|
||||||
|
Loading…
Reference in New Issue
Block a user