[FIX] web: load binary data in separate http req
The `read` done by `_fetchRecord` in `basic_model.js` expicitly set a `bin_size: true` in the context. That context option tells the backend to send the size of the binary payload instead of the payload itself thus slim the response size. Frontend widgets are then responsible to fetch the actual payload in a separated http req. The `search_read` done by `_searchReadUngroupedList` didn't set the context option thus all the binary fields were sent b64 encoded along with the `search_read` response. opw-1963842 closes odoo/odoo#33014 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -854,7 +854,7 @@ QUnit.test("Views should be loaded in the user's language", async function (asse
|
||||
'The views should be loaded with the correct context');
|
||||
}
|
||||
if (route === "/web/dataset/search_read") {
|
||||
assert.deepEqual(args.context, {lang: 'fr_FR'},
|
||||
assert.equal(args.context.lang, 'fr_FR',
|
||||
'The data should be loaded with the correct context');
|
||||
}
|
||||
if (route === '/web/action/load') {
|
||||
|
||||
@@ -4572,7 +4572,7 @@ var BasicModel = AbstractModel.extend({
|
||||
route: '/web/dataset/search_read',
|
||||
model: list.model,
|
||||
fields: fieldNames,
|
||||
context: list.getContext(),
|
||||
context: _.extend({}, list.getContext(), {bin_size: true}),
|
||||
domain: list.domain || [],
|
||||
limit: list.limit,
|
||||
offset: list.loadMoreOffset + list.offset,
|
||||
|
||||
@@ -85,7 +85,7 @@ QUnit.module('Views', {
|
||||
QUnit.module('KanbanView');
|
||||
|
||||
QUnit.test('basic ungrouped rendering', async function (assert) {
|
||||
assert.expect(5);
|
||||
assert.expect(6);
|
||||
|
||||
var kanban = await createView({
|
||||
View: KanbanView,
|
||||
@@ -97,6 +97,11 @@ QUnit.module('Views', {
|
||||
'<field name="foo"/>' +
|
||||
'</div>' +
|
||||
'</t></templates></kanban>',
|
||||
mockRPC: function (route, args) {
|
||||
assert.ok(args.context.bin_size,
|
||||
"should not request direct binary payload");
|
||||
return this._super(route, args);
|
||||
},
|
||||
});
|
||||
|
||||
assert.hasClass(kanban.$('.o_kanban_view'), 'o_kanban_ungrouped');
|
||||
|
||||
@@ -725,8 +725,8 @@ QUnit.module('Search View', {
|
||||
await testUtils.dom.click($('.o_menu_item:contains(AAA)'));
|
||||
|
||||
assert.verifySteps([
|
||||
"{}",
|
||||
"{\"coucou_1\":1}",
|
||||
"{\"bin_size\":true}",
|
||||
"{\"coucou_1\":1,\"bin_size\":true}",
|
||||
]);
|
||||
|
||||
actionManager.destroy();
|
||||
@@ -998,10 +998,10 @@ QUnit.module('Search View', {
|
||||
if (route === '/web/dataset/search_read') {
|
||||
if (searchRead === 1) {
|
||||
assert.deepEqual(args.domain, [["bar", "=", 1]]);
|
||||
assert.deepEqual(args.context, {'bar': [1]});
|
||||
assert.deepEqual(args.context.bar, [1]);
|
||||
} else if (searchRead === 2) {
|
||||
assert.deepEqual(args.domain, ["|", ["bar", "=", 1], ["bar", "=", 2]]);
|
||||
assert.deepEqual(args.context, { 'bar': [1, 2] });
|
||||
assert.deepEqual(args.context.bar, [1, 2]);
|
||||
}
|
||||
searchRead++;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ QUnit.module('Views', {
|
||||
if (search === 0 && route === '/web/dataset/search_read') {
|
||||
search++;
|
||||
assert.deepEqual(args, {
|
||||
context: {},
|
||||
context: {'bin_size': true}, // not part of the test, may change
|
||||
domain: [["display_name", "like", "a"], "&", ["display_name", "ilike", "piou"], ["foo", "ilike", "piou"]],
|
||||
fields: ["display_name", "foo"],
|
||||
model: "partner",
|
||||
@@ -169,7 +169,7 @@ QUnit.module('Views', {
|
||||
}, "should search with the complete domain (domain + search)");
|
||||
} else if (search === 1 && route === '/web/dataset/search_read') {
|
||||
assert.deepEqual(args, {
|
||||
context: {},
|
||||
context: {'bin_size': true}, // not part of the test, may change
|
||||
domain: [["display_name", "like", "a"]],
|
||||
fields: ["display_name", "foo"],
|
||||
model: "partner",
|
||||
|
||||
Reference in New Issue
Block a user