summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2019-03-14 14:10:54 +0000
committerSébastien Theys <seb@odoo.com>2019-03-14 14:10:54 +0000
commitfec83667bb7743b5474971deafe861c33fcc2cc1 (patch)
tree70ba36ce359069cc1312df2a88557219d4c7fe50 /addons/web/static/src/js
parente73ad6127e7aad8a10b522938ed8f8d0fe8e4e60 (diff)
[FIX] web: fix kanban_image when called for a different record
The issue is manifesting for example in the Contact kanban view where the company image should be displayed in small. Before this fix, the person image was displayed twice instead. Following PR #30881 and commit: f78b7a76d62d6b5f3e82f2f4a02b14981859df1f The fix introduced by the above commit highlighted another issue with the method: if the `model` and `id` given in parameter are different than the current record, the method returned the url for the current record instead of the requested record. To fix the issue, we return the `raw_value` only if the requested record is the current record. Otherwise, we return the manually built url. PR: #31842 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/views/kanban/kanban_record.js24
1 files changed, 15 insertions, 9 deletions
diff --git a/addons/web/static/src/js/views/kanban/kanban_record.js b/addons/web/static/src/js/views/kanban/kanban_record.js
index 48f1aacf4ad..94621211d2d 100644
--- a/addons/web/static/src/js/views/kanban/kanban_record.js
+++ b/addons/web/static/src/js/views/kanban/kanban_record.js
@@ -182,24 +182,30 @@ var KanbanRecord = Widget.extend({
*/
_getImageURL: function (model, field, id, cache, options) {
options = options || {};
+ id = (_.isArray(id) ? id[0] : id) || false;
+ field = options.preview_image || field;
+ var isCurrentRecord = this.modelName === model && this.recordData.id === id;
var url;
- if (this.record[field] && this.record[field].raw_value && !utils.is_bin_size(this.record[field].raw_value)) {
+ if (isCurrentRecord && this.record[field] && this.record[field].raw_value && !utils.is_bin_size(this.record[field].raw_value)) {
// Use magic-word technique for detecting image type
url = 'data:image/' + this.file_type_magic_word[this.record[field].raw_value[0]] + ';base64,' + this.record[field].raw_value;
- } else if (this.record[field] && ! this.record[field].raw_value) {
+ } else if (!model || !field || !id || (isCurrentRecord && this.record[field] && !this.record[field].raw_value)) {
url = "/web/static/src/img/placeholder.png";
} else {
- if (_.isArray(id)) { id = id[0]; }
- if (!id) { id = undefined; }
- if (options.preview_image)
- field = options.preview_image;
- var unique = this.record.__last_update && this.record.__last_update.value.replace(/[^0-9]/g, '');
var session = this.getSession();
- url = session.url('/web/image', {model: model, field: field, id: id, unique: unique});
+ var params = {
+ model: model,
+ field: field,
+ id: id
+ };
+ if (isCurrentRecord) {
+ params.unique = this.record.__last_update && this.record.__last_update.value.replace(/[^0-9]/g, '');
+ }
if (cache !== undefined) {
// Set the cache duration in seconds.
- url += '&cache=' + parseInt(cache, 10);
+ params.cache = parseInt(cache, 10);
}
+ url = session.url('/web/image', params);
}
return url;
},