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