diff options
| author | Martin Geubelle <mge@odoo.com> | 2017-04-25 16:05:58 +0200 |
|---|---|---|
| committer | Martin Geubelle <mge@odoo.com> | 2017-04-27 16:56:47 +0200 |
| commit | 67d7cbd06bbffaba6687dda9d4c883529d645e56 (patch) | |
| tree | e46f6410f8f71ea414b3ea0319f586908dba24b2 | |
| parent | e4ac74450f346f47d397a510d8efe65bd5fa0f1f (diff) | |
[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.
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 3 | ||||
| -rw-r--r-- | addons/web/static/tests/views/form_tests.js | 10 |
2 files changed, 7 insertions, 6 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index ad9e3fbeed1..3247a2806ef 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -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]; diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js index 76ab818809e..746c15f50e8 100644 --- a/addons/web/static/tests/views/form_tests.js +++ b/addons/web/static/tests/views/form_tests.js @@ -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); }, |
