[IMP] mail_tracking: Convert 'partner_trackings' to dict
This commit is contained in:
parent
7ef6c69205
commit
d3ddffb54b
@ -69,9 +69,13 @@ class MailMessage(models.Model):
|
|||||||
status = self._partner_tracking_status_get(tracking)
|
status = self._partner_tracking_status_get(tracking)
|
||||||
recipient = (
|
recipient = (
|
||||||
tracking.partner_id.name or tracking.recipient)
|
tracking.partner_id.name or tracking.recipient)
|
||||||
partner_trackings.append((
|
partner_trackings.append({
|
||||||
status, tracking.id, recipient, tracking.partner_id.id,
|
'status': status,
|
||||||
False))
|
'tracking_id': tracking.id,
|
||||||
|
'recipient': recipient,
|
||||||
|
'partner_id': tracking.partner_id.id,
|
||||||
|
'isCc': False,
|
||||||
|
})
|
||||||
if tracking.partner_id:
|
if tracking.partner_id:
|
||||||
email_cc_list.discard(tracking.partner_id.email)
|
email_cc_list.discard(tracking.partner_id.email)
|
||||||
partners_already |= tracking.partner_id
|
partners_already |= tracking.partner_id
|
||||||
@ -84,17 +88,27 @@ class MailMessage(models.Model):
|
|||||||
partners -= partners_already
|
partners -= partners_already
|
||||||
for partner in partners:
|
for partner in partners:
|
||||||
# If there is partners not included, then status is 'unknown'
|
# If there is partners not included, then status is 'unknown'
|
||||||
# Because can be an Cc recipinet
|
# Because can be an Cc recipient
|
||||||
isCc = False
|
isCc = False
|
||||||
if partner.email in email_cc_list:
|
if partner.email in email_cc_list:
|
||||||
email_cc_list.discard(partner.email)
|
email_cc_list.discard(partner.email)
|
||||||
isCc = True
|
isCc = True
|
||||||
partner_trackings.append((
|
partner_trackings.append({
|
||||||
'unknown', False, partner.name, partner.id, isCc))
|
'status': 'unknown',
|
||||||
|
'tracking_id': False,
|
||||||
|
'recipient': partner.name,
|
||||||
|
'partner_id': partner.id,
|
||||||
|
'isCc': isCc,
|
||||||
|
})
|
||||||
for email in email_cc_list:
|
for email in email_cc_list:
|
||||||
# If there is Cc without partner
|
# If there is Cc without partner
|
||||||
partner_trackings.append((
|
partner_trackings.append({
|
||||||
'unknown', False, email, False, True))
|
'status': 'unknown',
|
||||||
|
'tracking_id': False,
|
||||||
|
'recipient': email,
|
||||||
|
'partner_id': False,
|
||||||
|
'isCc': True,
|
||||||
|
})
|
||||||
res[message.id] = partner_trackings
|
res[message.id] = partner_trackings
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -119,7 +119,6 @@ odoo.define('mail_tracking.partner_tracking', function(require){
|
|||||||
_preprocess_message: function () {
|
_preprocess_message: function () {
|
||||||
var msg = this._super.apply(this, arguments);
|
var msg = this._super.apply(this, arguments);
|
||||||
msg.partner_trackings = msg.partner_trackings || [];
|
msg.partner_trackings = msg.partner_trackings || [];
|
||||||
msg.email_cc = msg.email_cc || [];
|
|
||||||
var needs_action = msg.track_needs_action;
|
var needs_action = msg.track_needs_action;
|
||||||
var message_track = _.findWhere(messages_tracked_changes, {
|
var message_track = _.findWhere(messages_tracked_changes, {
|
||||||
id: msg.id,
|
id: msg.id,
|
||||||
|
@ -5,39 +5,39 @@
|
|||||||
<template>
|
<template>
|
||||||
|
|
||||||
<t t-name="mail.tracking.status">
|
<t t-name="mail.tracking.status">
|
||||||
<t t-if="tracking[4]">
|
<t t-if="tracking['isCc']">
|
||||||
<span class="mail_tracking_cc">
|
<span class="mail_tracking_cc">
|
||||||
<i class="fa fa-cc"></i>
|
<i class="fa fa-cc"></i>
|
||||||
</span>
|
</span>
|
||||||
</t>
|
</t>
|
||||||
<t t-elif="tracking[0] === 'unknown'">
|
<t t-elif="tracking['status'] === 'unknown'">
|
||||||
<span class="mail_tracking_unknown">
|
<span class="mail_tracking_unknown">
|
||||||
<i class="fa fa-ban"></i>
|
<i class="fa fa-ban"></i>
|
||||||
</span>
|
</span>
|
||||||
</t>
|
</t>
|
||||||
<t t-elif="tracking[0] === 'waiting'">
|
<t t-elif="tracking['status'] === 'waiting'">
|
||||||
<span class="mail_tracking_waiting mail_tracking_pointer">
|
<span class="mail_tracking_waiting mail_tracking_pointer">
|
||||||
<i class="fa fa-clock-o"></i>
|
<i class="fa fa-clock-o"></i>
|
||||||
</span>
|
</span>
|
||||||
</t>
|
</t>
|
||||||
<t t-elif="tracking[0] === 'error'">
|
<t t-elif="tracking['status'] === 'error'">
|
||||||
<span class="mail_tracking_error mail_tracking_pointer">
|
<span class="mail_tracking_error mail_tracking_pointer">
|
||||||
<i class="fa fa-remove"></i>
|
<i class="fa fa-remove"></i>
|
||||||
</span>
|
</span>
|
||||||
</t>
|
</t>
|
||||||
<t t-elif="tracking[0] === 'sent'">
|
<t t-elif="tracking['status'] === 'sent'">
|
||||||
<span class="mail_tracking_sent mail_tracking_pointer">
|
<span class="mail_tracking_sent mail_tracking_pointer">
|
||||||
<i class="fa fa-check"></i>
|
<i class="fa fa-check"></i>
|
||||||
</span>
|
</span>
|
||||||
</t>
|
</t>
|
||||||
<t t-elif="tracking[0] === 'delivered'">
|
<t t-elif="tracking['status'] === 'delivered'">
|
||||||
<span class="fa-stack mail_tracking_delivered mail_tracking_pointer">
|
<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-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-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:-3px"></i>
|
||||||
</span>
|
</span>
|
||||||
</t>
|
</t>
|
||||||
<t t-elif="tracking[0] === 'opened'">
|
<t t-elif="tracking['status'] === 'opened'">
|
||||||
<span class="fa-stack mail_tracking_opened mail_tracking_pointer">
|
<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-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-inverse fa-stack-1x" style="margin-left:-2px;"></i>
|
||||||
@ -55,19 +55,19 @@
|
|||||||
<t t-if="!tracking_first">
|
<t t-if="!tracking_first">
|
||||||
-
|
-
|
||||||
</t>
|
</t>
|
||||||
<t t-if="tracking[3]">
|
<t t-if="tracking['partner_id']">
|
||||||
<a t-attf-class="o_mail_action_tracking_partner #{tracking[4] ? 'o_mail_cc' : ''}"
|
<a t-attf-class="o_mail_action_tracking_partner #{tracking['isCc'] ? 'o_mail_cc' : ''}"
|
||||||
t-att-data-partner="tracking[3]"
|
t-att-data-partner="tracking['partner_id']"
|
||||||
t-attf-href="#model=res.partner&id=#{tracking[3]}">
|
t-attf-href="#model=res.partner&id=#{tracking['partner_id']}">
|
||||||
<t t-esc="tracking[2]"/>
|
<t t-esc="tracking['recipient']"/>
|
||||||
</a>
|
</a>
|
||||||
</t>
|
</t>
|
||||||
<t t-if="!tracking[3]">
|
<t t-else="">
|
||||||
<span t-attf-class="#{tracking[4] ? 'o_mail_cc' : ''}"><t t-esc="tracking[2]"/></span>
|
<span t-attf-class="#{tracking['isCc'] ? 'o_mail_cc' : ''}"><t t-esc="tracking['recipient']"/></span>
|
||||||
</t>
|
</t>
|
||||||
<span class="mail_tracking o_mail_action_tracking_status"
|
<span class="mail_tracking o_mail_action_tracking_status"
|
||||||
t-att-data-tracking="tracking[1]"
|
t-att-data-tracking="tracking['tracking_id']"
|
||||||
t-attf-title="Status: #{tracking[0]}">
|
t-attf-title="Status: #{tracking['status']}">
|
||||||
<t t-call="mail.tracking.status"/>
|
<t t-call="mail.tracking.status"/>
|
||||||
</span>
|
</span>
|
||||||
</t>
|
</t>
|
||||||
|
@ -101,10 +101,11 @@ class TestMailTracking(TransactionCase):
|
|||||||
status = message_dict['partner_trackings'][0]
|
status = message_dict['partner_trackings'][0]
|
||||||
# Tracking status must be sent and
|
# Tracking status must be sent and
|
||||||
# mail tracking must be the one search before
|
# mail tracking must be the one search before
|
||||||
self.assertEqual(status[0], 'sent')
|
self.assertEqual(status['status'], 'sent')
|
||||||
self.assertEqual(status[1], tracking_email.id)
|
self.assertEqual(status['tracking_id'], tracking_email.id)
|
||||||
self.assertEqual(status[2], self.recipient.display_name)
|
self.assertEqual(status['recipient'], self.recipient.display_name)
|
||||||
self.assertEqual(status[3], self.recipient.id)
|
self.assertEqual(status['partner_id'], self.recipient.id)
|
||||||
|
self.assertEqual(status['isCc'], False)
|
||||||
# And now open the email
|
# And now open the email
|
||||||
metadata = {
|
metadata = {
|
||||||
'ip': '127.0.0.1',
|
'ip': '127.0.0.1',
|
||||||
@ -122,15 +123,15 @@ class TestMailTracking(TransactionCase):
|
|||||||
foundPartner = False
|
foundPartner = False
|
||||||
foundNoPartner = False
|
foundNoPartner = False
|
||||||
for tracking in message_dict['partner_trackings']:
|
for tracking in message_dict['partner_trackings']:
|
||||||
if tracking[3] == self.sender.id:
|
if tracking['partner_id'] == self.sender.id:
|
||||||
foundPartner = True
|
foundPartner = True
|
||||||
self.assertTrue(tracking[4])
|
self.assertTrue(tracking['isCc'])
|
||||||
elif tracking[2] == 'unnamed@test.com':
|
elif tracking['recipient'] == 'unnamed@test.com':
|
||||||
foundNoPartner = True
|
foundNoPartner = True
|
||||||
self.assertFalse(tracking[3])
|
self.assertFalse(tracking['partner_id'])
|
||||||
self.assertTrue(tracking[4])
|
self.assertTrue(tracking['isCc'])
|
||||||
elif tracking[3] == self.recipient.id:
|
elif tracking['partner_id'] == self.recipient.id:
|
||||||
self.assertFalse(tracking[4])
|
self.assertFalse(tracking['isCc'])
|
||||||
self.assertTrue(foundPartner)
|
self.assertTrue(foundPartner)
|
||||||
self.assertTrue(foundNoPartner)
|
self.assertTrue(foundNoPartner)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user