From c6e7e2d2aacbaf6c3685ae30b45a01ecf5d1a426 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Tue, 5 Jul 2016 11:27:18 +0200 Subject: [PATCH] [FIX] mail: controller avatar return placeholder if no content binary_content return '' if no picture, so, we keep the placeholder if no image has been returned. It avoid in the new portal with discuss widget to get the default browser 404 picture (file broken) This commit close #12683 --- addons/mail/controllers/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/mail/controllers/main.py b/addons/mail/controllers/main.py index c67238e46d0..320020d2c6f 100644 --- a/addons/mail/controllers/main.py +++ b/addons/mail/controllers/main.py @@ -222,7 +222,10 @@ class MailController(http.Controller): # if the current user has access to the document, get the partner avatar as sudo() request.env[res_model].browse(res_id).check_access_rule('read') if partner_id in request.env[res_model].browse(res_id).sudo().exists().message_ids.mapped('author_id').ids: - status, headers, content = binary_content(model='res.partner', id=partner_id, field='image_medium', default_mimetype='image/png', env=request.env(user=openerp.SUPERUSER_ID)) + status, headers, _content = binary_content(model='res.partner', id=partner_id, field='image_medium', default_mimetype='image/png', env=request.env(user=openerp.SUPERUSER_ID)) + # binary content return an empty string and not a placeholder if obj[field] is False + if _content != '': + content = _content if status == 304: return werkzeug.wrappers.Response(status=304) except AccessError: