[FIX] mail: make red envelope visible when necessary

We need to know if a notification is in failure by
displaying the red envelope in even if all partner are inactive.

This commit also fix the filter in order to display notification
of all active partners if there is an exception.
This commit is contained in:
XavierDo
2018-09-06 10:34:14 +02:00
committed by Olivier Dony
parent 554414b90f
commit 62928bb81a
2 changed files with 15 additions and 7 deletions
+13 -6
View File
@@ -372,10 +372,19 @@ class Message(models.Model):
else:
partner_ids = [partner_tree[partner.id] for partner in message.partner_ids
if partner.id in partner_tree]
# we read customer_email_status before filtering inactive user because we don't want to miss a red enveloppe
customer_email_status = (
(all(n.email_status == 'sent' for n in message.notification_ids) and 'sent') or
(any(n.email_status == 'exception' for n in message.notification_ids) and 'exception') or
(any(n.email_status == 'bounce' for n in message.notification_ids) and 'bounce') or
'ready'
)
customer_email_data = []
filter_notification = lambda notif: (notif.email_status in ('bounce', 'exception', 'canceled') and (notif.res_partner_id.partner_share and notif.res_partner_id.active)) or\
(notif.res_partner_id.partner_share and notif.res_partner_id.active)
def filter_notification(notif):
return (
(notif.email_status in ('bounce', 'exception', 'canceled') or notif.res_partner_id.partner_share) and
notif.res_partner_id.active
)
for notification in message.notification_ids.filtered(filter_notification):
customer_email_data.append((partner_tree[notification.res_partner_id.id][0], partner_tree[notification.res_partner_id.id][1], notification.email_status))
@@ -391,9 +400,7 @@ class Message(models.Model):
message_dict.update({
'author_id': author,
'partner_ids': partner_ids,
'customer_email_status': (all(d[2] == 'sent' for d in customer_email_data) and 'sent') or
(any(d[2] == 'exception' for d in customer_email_data) and 'exception') or
(any(d[2] == 'bounce' for d in customer_email_data) and 'bounce') or 'ready',
'customer_email_status': customer_email_status,
'customer_email_data': customer_email_data,
'attachment_ids': attachment_ids,
'tracking_value_ids': tracking_value_ids,
+2 -1
View File
@@ -174,7 +174,8 @@
<t t-if="message.origin_id and (message.origin_id !== options.channel_id)">
(from <a t-att-data-oe-id="message.origin_id" href="#">#<t t-esc="message.origin_name"/></a>)
</t>
<span t-if="options.display_email_icon and message.customer_email_data and message.customer_email_data.length" class="o_thread_tooltip_container">
<span t-if="options.display_email_icon and ((message.customer_email_data and message.customer_email_data.length) or ['exception', 'bounce'].indexOf(message.customer_email_status) > -1)" class="o_thread_tooltip_container">
<t t-set="fatype" t-value="''"/>
<t t-if="message.customer_email_status === 'sent' or message.customer_email_status === 'ready'">
<t t-set="fatype" t-value="'-o'"/>