From ecceee639ed7bfdaf0e2e152fd147ee02e3281e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Sun, 26 Feb 2017 09:24:45 +0100 Subject: [FIX] web: formview dialog can now properly evaluate context For this change, I had to pass the handle to the parent datapoint all the way from the controller to the new form view. --- .../static/test/fields/relational_fields_tests.js | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'addons/web/static/test/fields/relational_fields_tests.js') diff --git a/addons/web/static/test/fields/relational_fields_tests.js b/addons/web/static/test/fields/relational_fields_tests.js index c76c5bdebe0..63dc28f697d 100644 --- a/addons/web/static/test/fields/relational_fields_tests.js +++ b/addons/web/static/test/fields/relational_fields_tests.js @@ -1359,6 +1359,49 @@ QUnit.module('relational_fields', { form.$buttons.find('.o_form_button_save').click(); }); + QUnit.test('one2many list with inline form view with context with parent key', function (assert) { + assert.expect(2); + + this.data.partner.records[0].p = [2]; + this.data.partner.records[0].product_id = 41; + this.data.partner.records[1].product_id = 37; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '', + res_id: 1, + mockRPC: function (route, args) { + if (args.method === 'name_search') { + assert.strictEqual(args.kwargs.context.partner_foo, "yop", + "should have correctly evaluated parent foo field"); + assert.strictEqual(args.kwargs.context.lalala, 41, + "should have correctly evaluated parent product_id field"); + } + return this._super.apply(this, arguments); + }, + }); + + form.$buttons.find('.o_form_button_edit').click(); + // open a modal + form.$('tr.o_data_row:eq(0) td:contains(xphone)').click(); + + // write in the many2one field + $('.modal .o_form_field_many2one input').click(); + }); + QUnit.test('one2many list edition, some basic functionality', function (assert) { assert.expect(3); -- cgit v1.2.3