From f1b9b301da5d3928f10a6636297f9af9b006ab98 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 24 Mar 2016 11:18:14 +0100 Subject: [PATCH] [FIX] web: clear filename if image error When the user chooses as product image a file which is not an image, the message "Could not display the selected image" is displayed. However, at saving, a traceback is thrown since the file chosen is uploaded anyway. If the image cannot be displayed, the image field is cleared. opw-672206 --- addons/web/static/src/js/view_form.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 0874792003f..d243c9b1062 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -5229,6 +5229,7 @@ instance.web.form.FieldBinaryImage = instance.web.form.FieldBinary.extend({ $img.css("margin-top", "" + (self.options.size[1] - $img.height()) / 2 + "px"); }); $img.on('error', function() { + self.on_clear(); $img.attr('src', self.placeholder); instance.webclient.notification.warn(_t("Image"), _t("Could not display the selected image.")); });