From ea4c93472879f042f8aa343d5c42fa6c2bd5cfce Mon Sep 17 00:00:00 2001 From: Damien Bouvy Date: Tue, 17 Dec 2019 16:29:13 +0000 Subject: [PATCH] [IMP] web: allow background-style images for custom models The `FieldBinaryImage` assumes that the image mixin is used to manage its fields - this is mostly true, until you use custom fields. This commit makes using the 'background' option of the Image widget possible by fallbacking the thumbnail field's name to the name of the field itself instead of `image_128` when we're dealing with a custom field. --- addons/web/static/src/js/fields/basic_fields.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 996e759a70a..f2c44891ea2 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1875,7 +1875,8 @@ var FieldBinaryImage = AbstractFieldBinary.extend({ this.$el.addClass(this.attrs.class); } - var urlThumb = this._getImageUrl(this.model, this.res_id, 'image_128', unique); + const image_field = this.field.manual ? this.name:'image_128'; + var urlThumb = this._getImageUrl(this.model, this.res_id, image_field, unique); this.$el.empty(); $img = this.$el;