summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavierDo <xdo@odoo.com>2018-09-05 18:19:59 +0200
committerOlivier Dony <odo@odoo.com>2018-09-06 10:34:14 +0200
commit62928bb81a2ff0867cb620db9c35b4680e750d32 (patch)
treeef4fbd2a540a2672aeb12728fa798f9bf523fc89
parent554414b90fde3ee0e216e02e0ab0c81f6735b38d (diff)
[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.
-rw-r--r--addons/mail/models/mail_message.py19
-rw-r--r--addons/mail/static/src/xml/thread.xml3
2 files changed, 15 insertions, 7 deletions
diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py
index d581a42e1ee..cd55e1f71d1 100644
--- a/addons/mail/models/mail_message.py
+++ b/addons/mail/models/mail_message.py
@@ -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,
diff --git a/addons/mail/static/src/xml/thread.xml b/addons/mail/static/src/xml/thread.xml
index ca8ae9b8319..325f274f958 100644
--- a/addons/mail/static/src/xml/thread.xml
+++ b/addons/mail/static/src/xml/thread.xml
@@ -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'"/>