From d7eb116fa8b9d5e9cd75f628a3a9e6e53fcbd744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Tue, 28 Feb 2017 16:17:28 +0100 Subject: [FIX] web: properly compute contexts in some cases When we have a many2one widget in a one2many, editable, the context was not properly computed: it expected the parent to be a record object, but in that case, it is a list object. --- .../static/test/fields/relational_fields_tests.js | 38 ++++++++++++++++++++++ 1 file changed, 38 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 294a3cb44d5..583f9adfdd1 100644 --- a/addons/web/static/test/fields/relational_fields_tests.js +++ b/addons/web/static/test/fields/relational_fields_tests.js @@ -1431,6 +1431,44 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('one2many list, editable, with many2one and with context with parent key', function (assert) { + assert.expect(1); + + this.data.partner.records[0].p = [2]; + 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"); + } + return this._super.apply(this, arguments); + }, + }); + + form.$buttons.find('.o_form_button_edit').click(); + + form.$('tr.o_data_row:eq(0) td:contains(xphone)').click(); + + // trigger a name search + form.$('table td input.o_form_input').click(); + + form.destroy(); + }); + QUnit.test('one2many list edition, some basic functionality', function (assert) { assert.expect(3); -- cgit v1.2.3