[FIX] web: fix image cache in kanban/activity view
The way we cache the image is not right when that image is not on the current record. For instance displaying a partner/user image. The unique key used is not related to that record. Introduced by https://github.com/odoo/odoo/pull/97544 closes odoo/odoo#157199 X-original-commit: d127ec26d8e8d42c0e25668797cbd0f37203dc52 Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com> Signed-off-by: fja-odoo <fja@odoo.com>
This commit is contained in:
@@ -1393,9 +1393,7 @@ QUnit.module("test_mail", {}, function () {
|
||||
assert.ok(
|
||||
target
|
||||
.querySelector(".o_activity_record img")
|
||||
.dataset.src.endsWith(
|
||||
"/web/image?model=partner&field=image&id=2&unique=1659688620000"
|
||||
),
|
||||
.dataset.src.endsWith("/web/image?model=partner&field=image&id=2"),
|
||||
"image src is the preview image given in option"
|
||||
);
|
||||
});
|
||||
|
||||
@@ -149,12 +149,15 @@ export function getImageSrcFromRecordInfo(record, model, field, idOrIds, placeho
|
||||
return placeholder;
|
||||
} else {
|
||||
// Else: fetches the image related to the given id.
|
||||
return url("/web/image", {
|
||||
const params = {
|
||||
model,
|
||||
field,
|
||||
id,
|
||||
unique: imageCacheKey(record.data.write_date),
|
||||
});
|
||||
};
|
||||
if (isCurrentRecord) {
|
||||
params.unique = imageCacheKey(record.data.write_date);
|
||||
}
|
||||
return url("/web/image", params);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10916,12 +10916,12 @@ QUnit.module("Views", (hooks) => {
|
||||
});
|
||||
assert.containsOnce(
|
||||
target,
|
||||
'img[data-src*="/web/image"][data-src$="&id=1&unique="]',
|
||||
'img[data-src*="/web/image"][data-src$="&id=1"]',
|
||||
"image url should contain id of set partner_id"
|
||||
);
|
||||
assert.containsOnce(
|
||||
target,
|
||||
'img[data-src*="/web/image"][data-src$="&id=&unique="]',
|
||||
'img[data-src*="/web/image"][data-src$="&id="]',
|
||||
"image url should contain an empty id if partner_id is not set"
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user