Browse Source

[FIX] Handle byte encoded string from ldap

14.0
Andrea 4 years ago
parent
commit
f5d7db83f9
  1. 5
      partner_firstname/models/res_partner.py

5
partner_firstname/models/res_partner.py

@ -127,6 +127,11 @@ class ResPartner(models.Model):
Removes leading, trailing and duplicated whitespace. Removes leading, trailing and duplicated whitespace.
""" """
if isinstance(name, bytes):
# With users coming from LDAP, name can be a byte encoded string.
# This happens with FreeIPA for instance.
name = name.decode("utf-8")
try: try:
name = " ".join(name.split()) if name else name name = " ".join(name.split()) if name else name
except UnicodeDecodeError: except UnicodeDecodeError:

Loading…
Cancel
Save