From f45edfbe6d03b15977392dda9561cd7a3e16ce34 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Mon, 23 Oct 2017 11:53:29 +0200 Subject: [FIX] web: image widget is dependent on its record's last_update As a way to optimize loading, images are not necessarily fetched in db. They have, in their url a "unique" parameter, which is the last_update date on **the record** and controls on the python-side whether it should get the image from a cache or from the db. Before this commit, this __last_update field wasn't present in the view, so it wasn't fetched, and writes on a model's image worked but did not refresh. The image displayed was the old one. After this commit, when the image field widget is present, we force the loading of the __last_update field of the record. Upon update, the image displayed is the new one. OPW 777552 closes #20457 --- addons/web/static/tests/fields/basic_fields_tests.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'addons/web/static/tests/fields/basic_fields_tests.js') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index f05d7abf08e..1d1eccf207d 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1427,8 +1427,10 @@ QUnit.module('basic_fields', { QUnit.module('FieldImage'); QUnit.test('image fields are correctly rendered', function (assert) { - assert.expect(5); + assert.expect(6); + this.data.partner.fields.__last_update = {string: "Last updated", type: "datetime"}; + this.data.partner.records[0].__last_update = '2017-02-08 10:00:00'; this.data.partner.records[0].document = 'myimage'; var form = createView({ @@ -1439,7 +1441,10 @@ QUnit.module('basic_fields', { ' ' + '', res_id: 1, - mockRPC: function (route) { + mockRPC: function (route, args) { + if (route === '/web/dataset/call_kw/partner/read') { + assert.deepEqual(args.args[1], ['document', '__last_update', 'display_name'], "The fields document, display_name and __last_update should be present when reading an image"); + } if (route === 'data:image/png;base64,myimage') { assert.ok(true, "should called the correct route"); return $.when('wow'); -- cgit v1.2.3