From f5d7db83f91af4a1100ab89bbc98e31e42303b97 Mon Sep 17 00:00:00 2001 From: Andrea Date: Mon, 16 Nov 2020 12:03:51 +0100 Subject: [PATCH] [FIX] Handle byte encoded string from ldap --- partner_firstname/models/res_partner.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/partner_firstname/models/res_partner.py b/partner_firstname/models/res_partner.py index db677410d..0a62e0b61 100644 --- a/partner_firstname/models/res_partner.py +++ b/partner_firstname/models/res_partner.py @@ -127,6 +127,11 @@ class ResPartner(models.Model): 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: name = " ".join(name.split()) if name else name except UnicodeDecodeError: