From 90603b78787812fd6d16efadaa2f1ca0ca9335bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 20 Aug 2018 22:41:56 +0200 Subject: [PATCH] Fix contact_mechanism_get usage The contact_mechanism_get returns a contact mechanism instance and not the value. Also the contact mechanism should be used as name if filled. issue7623 review49531002 --- notification.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/notification.py b/notification.py index cd6fcbfe24..da0743c1b9 100644 --- a/notification.py +++ b/notification.py @@ -152,10 +152,11 @@ class Email(ModelSQL, ModelView): if isinstance(record, User) and record.email: return _formataddr(record.rec_name, record.email) elif Party and isinstance(record, Party): - email = record.contact_mechanism_get( + contact = record.contact_mechanism_get( 'email', usage=self.contact_mechanism) - if email: - return _formataddr(record.rec_name, email) + if contact and contact.email: + return _formataddr( + contact.name or record.rec_name, contact.email) elif WebUser and isinstance(record, WebUser): name = None if record.party: