From 54d2c64a5ff2a6ac24a62cf44224b77fa801a116 Mon Sep 17 00:00:00 2001 From: Daniel Reis Date: Wed, 21 Aug 2013 11:38:55 +0100 Subject: [PATCH] FIX no warning messages when an attribute definition is not set --- users_ldap_mail/users_ldap_model.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/users_ldap_mail/users_ldap_model.py b/users_ldap_mail/users_ldap_model.py index dd447ec3b..a05ac0c50 100644 --- a/users_ldap_mail/users_ldap_model.py +++ b/users_ldap_mail/users_ldap_model.py @@ -28,9 +28,10 @@ class CompanyLDAP(orm.Model): _inherit = 'res.company.ldap' _columns = { 'name_attribute': fields.char('Name Attribute', size=64, - help="Default in 'cn'. For an AD you could use 'displayName' instead."), + help="By default 'cn' is used. " + "For ActiveDirectory you might use 'displayName' instead."), 'mail_attribute': fields.char('E-mail attribute', size=64, - help="Active Directory uses the 'mail' attribute."), + help="LDAP attribute to use to retrieve em-mail address."), } _defaults = { 'mail_attribute': 'mail', @@ -63,7 +64,8 @@ class CompanyLDAP(orm.Model): ] for value_key, conf_name in mapping: try: - values[value_key] = ldap_entry[1][conf[conf_name]][0] + if conf[conf_name]: + values[value_key] = ldap_entry[1][conf[conf_name]][0] except KeyError: _log.warning('No LDAP attribute "%s" found for login "%s"' % ( conf.get(conf_name), values.get('login')))