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
This commit is contained in:
Cédric Krier
2018-08-20 22:41:56 +02:00
parent f9396feed2
commit 90603b7878
+4 -3
View File
@@ -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: