From 3632949cffb24180832e18a3f19a6d02bd8e8729 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 11 Aug 2014 14:39:50 +0200 Subject: [PATCH] [FIX] web: image fields re-render on next/previous By default, on binary images read, the server returns the binary size This is possible that two images have the exact same size Therefore we trigger the change in case the image value hasn't changed So the image is re-rendered correctly --- addons/web/static/src/js/view_form.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index e91955e0a4e..08050c7d686 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -5194,6 +5194,20 @@ instance.web.form.FieldBinaryImage = instance.web.form.FieldBinary.extend({ this._super.apply(this, arguments); this.render_value(); this.set_filename(''); + }, + set_value: function(value_){ + var changed = value_ !== this.get_value(); + this._super.apply(this, arguments); + // By default, on binary images read, the server returns the binary size + // This is possible that two images have the exact same size + // Therefore we trigger the change in case the image value hasn't changed + // So the image is re-rendered correctly + if (!changed){ + this.trigger("change:value", this, { + oldValue: value_, + newValue: value_ + }); + } } });