diff options
| author | qsm-odoo <qsm@odoo.com> | 2017-02-23 17:52:23 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | cd6bba33c2b0b5960c596784dbfcc44b2c9f32d1 (patch) | |
| tree | e5fd8f6bb753dc913cf1a113716dcd998f71f6cd /addons/web/static/test | |
| parent | a9eac7766f6d45d08373595c96eb32aef8b60f3a (diff) | |
[IMP] web: auto-context for fields model RPC calls
Some fields need to do some model RPC calls (name_search, name_create,
...). Before this commit, they did not use the performModelRPC method
but an explicit trigger_up so that the BasicController (the
FieldManagerMixin) catches it and ask the BasicModel to perform the
RPC. This was designed to let the BasicModel handle the context.
This commit makes the context be automatically binded without the need
to explicitely call the BasicModel for each route in the
FieldManagerMixin. It also ensures that the field own context is
properly merged with the user/action/search contexts.
Now, the fields use the performModelRPC method and the
FieldManagerMixin catches the associated "call_service" event. Then, it
can get the full context from the BasicModel instance and let the event
continue its propagation. To know which field context has to be fetched,
the performModelRPC method is overriden by AbstractField to
automatically add the dataPointID and the field name in the options
parameter.
Diffstat (limited to 'addons/web/static/test')
| -rw-r--r-- | addons/web/static/test/fields/relational_fields_tests.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/addons/web/static/test/fields/relational_fields_tests.js b/addons/web/static/test/fields/relational_fields_tests.js index 6ed77912896..cfbbeacc2c2 100644 --- a/addons/web/static/test/fields/relational_fields_tests.js +++ b/addons/web/static/test/fields/relational_fields_tests.js @@ -399,6 +399,41 @@ QUnit.module('relational_fields', { assert.strictEqual(form.$('a').text(), '', 'the tag a should be empty'); }); + QUnit.test('check that the field context is used when doing a name_search in a m2o', function (assert) { + assert.expect(3); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: + '<form string="Partners">' + + '<field name="product_id" context="{\'hello\': \'world\', \'test\': foo}"/>' + + '<field name="foo"/>' + + '</form>', + res_id: 1, + session: {user_context: {hey: "ho"}}, + manualDestroy: true, + mockRPC: function (route, args) { + if (route === '/web/dataset/call_kw/product/name_search') { + var context = args.kwargs.context; + assert.strictEqual(context.hey, "ho", + 'the session context should have been used for the rpc'); + assert.strictEqual(context.hello, "world", + 'the field context should have been used for the RPC'); + assert.strictEqual(context.test, "yop", + 'the field context should have been properly evaluated'); + } + return this._super.apply(this, arguments); + }, + }); + + form.$buttons.find('.o_form_button_edit').click(); + form.$('input').first().click(); + + form.destroy(); + }); + QUnit.module('FieldOne2Many'); QUnit.test('one2many basic properties', function (assert) { |
