[FIX] web: pass bin_size in context

When fetching record, `bin_size` needs to be passed in the context
to notify the server to send the `bin_size` and not the whole base64
of binary fields.
This commit is contained in:
Martin Geubelle
2017-04-27 16:56:47 +02:00
parent e4ac74450f
commit 67d7cbd06b
2 changed files with 7 additions and 6 deletions
@@ -1253,8 +1253,7 @@ var BasicModel = AbstractModel.extend({
model: record.model,
method: 'read',
args: [[record.res_id], fieldNames],
context: record.context,
// context: {bin_size: true} // FIXME: when editing a subrecord in the partner form view, it tries to write the bin_size on the image field
context: _.extend({}, record.context, {bin_size: true}),
})
.then(function (result) {
result = result[0];
+6 -4
View File
@@ -161,8 +161,8 @@ QUnit.module('Views', {
form.destroy();
});
QUnit.test('only necessary fields are fetched', function (assert) {
assert.expect(1);
QUnit.test('only necessary fields are fetched with correct context', function (assert) {
assert.expect(2);
var form = createView({
View: FormView,
@@ -177,6 +177,8 @@ QUnit.module('Views', {
// field, not sure why. Maybe this test should be modified.
assert.deepEqual(args.args[1], ["foo", "display_name"],
"should only fetch requested fields");
assert.deepEqual(args.kwargs.context, {bin_size: true},
"bin_size should always be in the context");
return this._super(route, args);
}
});
@@ -3142,8 +3144,8 @@ QUnit.module('Views', {
},
mockRPC: function (route, args) {
if (args.method === 'read') {
assert.deepEqual(args.kwargs.context, {some_context: false},
"record's context shouldn't have been modified");
assert.strictEqual('some_context' in args.kwargs.context && !args.kwargs.context.some_context, true,
"the context should have been set");
}
return this._super.apply(this, arguments);
},