From 0e95e0cf92bef425511eb26d7dbbc1d5488a2dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 23 Mar 2012 11:05:13 +0100 Subject: [PATCH] [FIX] Fixed the last fix. Also cleaned a bit the code. bzr revid: tde@openerp.com-20120323100513-m2n5n3jtxz8zo1yl --- openerp/addons/base/res/res_users.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/openerp/addons/base/res/res_users.py b/openerp/addons/base/res/res_users.py index 6f28881b412..3827e5ef8c5 100644 --- a/openerp/addons/base/res/res_users.py +++ b/openerp/addons/base/res/res_users.py @@ -219,13 +219,13 @@ class users(osv.osv): return dict(zip(ids, ['extended' if user in extended_users else 'simple' for user in ids])) def onchange_avatar(self, cr, uid, ids, value, context=None): - return {'value': {'avatar_stored': value, 'avatar': self._avatar_resize(cr, uid, value, context=context) } } + return {'value': {'avatar_stored': self._avatar_resize(cr, uid, value, context=context), 'avatar': self._avatar_resize(cr, uid, value, context=context) } } def _set_avatar(self, cr, uid, id, name, value, args, context=None): return self.write(cr, uid, [id], {'avatar_stored': value}, context=context) def _avatar_resize(self, cr, uid, avatar, context=None): - image_stream = io.BytesIO(avatar_stored.decode('base64')) + image_stream = io.BytesIO(avatar.decode('base64')) img = Image.open(image_stream) img.thumbnail((180, 150), Image.ANTIALIAS) img_stream = StringIO.StringIO() @@ -233,11 +233,9 @@ class users(osv.osv): return img_stream.getvalue().encode('base64') def _get_avatar(self, cr, uid, ids, name, args, context=None): - result = {} + result = dict.fromkeys(ids, False) for user in self.browse(cr, uid, ids, context=context): - if not user.avatar: - result[user.id] = False - else: + if user.avatar_stored: result[user.id] = self._avatar_resize(cr, uid, user.avatar_stored) return result