diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-04-21 08:48:35 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-25 08:07:17 +0200 |
| commit | f5bfa3d3b653c8ec8a9a1820eeff995a7f954ca9 (patch) | |
| tree | 1cf332dc47268bc1006316d0d5d73b41189d9806 /addons/web/static/tests | |
| parent | 6e850085042ee0132157823a97da8ffe47a9279e (diff) | |
[FIX] web: FormView: don't modify record's context
Before this rev., some keys were added to the context of a record
if there were x2many fields in the form view with a context
defined on their node (containing *_view_ref keys, specifying the
fields_view to load to display the relational data). Those keys
should not be added to the main record's context, and it may cause
errors (e.g. click on the 'Procurements' stat button in the Product
form view).
Diffstat (limited to 'addons/web/static/tests')
| -rw-r--r-- | addons/web/static/tests/views/form_tests.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js index c780d2afa6f..8fdd76934b7 100644 --- a/addons/web/static/tests/views/form_tests.js +++ b/addons/web/static/tests/views/form_tests.js @@ -3084,7 +3084,7 @@ QUnit.module('Views', { QUnit.test('*_view_ref in context are passed correctly', function (assert) { var done = assert.async(); - assert.expect(1); + assert.expect(4); createAsyncView({ View: FormView, @@ -3095,15 +3095,30 @@ QUnit.module('Views', { '<field name="p" context="{\'tree_view_ref\':\'module.tree_view_ref\'}"/>' + '</sheet>' + '</form>', + res_id: 1, intercepts: { load_views: function (event) { - assert.strictEqual(event.data.context.eval().tree_view_ref, - 'module.tree_view_ref', + var context = event.data.context.eval(); + assert.strictEqual(context.tree_view_ref, 'module.tree_view_ref', "context should contain tree_view_ref"); + assert.notOk('some_context' in context, + "should not send record's context to load p's fields_view"); event.data.on_success(); } - } + }, + viewOptions: { + context: {some_context: false}, + }, + mockRPC: function (route, args) { + if (args.method === 'read') { + assert.deepEqual(args.kwargs.context, {some_context: false}, + "record's context shouldn't have been modified"); + } + return this._super.apply(this, arguments); + }, }).then(function (form) { + // reload to check that the record's context hasn't been modified + form.reload(); form.destroy(); done(); }); |
