From 68332a0177990020f11b94317a6d3a81ff906d69 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 17 Aug 2018 13:39:29 +0200 Subject: [FIX] web: fix evaluation context of the domain selector The domain was instantiated without being given any evaluation context. As a result, the uid variable was not defined, crashing the js if present in a user-defined filter. opw 1866852 --- .../web/static/tests/fields/basic_fields_tests.js | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'addons/web/static/tests/fields/basic_fields_tests.js') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index f2ab670f097..4dd595cbfa0 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -4345,6 +4345,33 @@ QUnit.module('basic_fields', { QUnit.module('FieldDomain'); + QUnit.test('The domain editor should not crash the view when given a dynamic filter', function (assert) { + //dynamic filters (containing variables, such as uid, parent or today) + //are not handled by the domain editor, but it shouldn't crash the view + assert.expect(1); + + this.data.partner.records[0].foo = '[["int_field", "=", uid]]'; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: + '
' + + '' + + '' + + '', + res_id: 1, + session: { + user_context: {uid: 14}, + }, + }); + + assert.strictEqual(form.$('.o_read_mode').text(), "This domain is not supported.", + "The widget should not crash the view, but gracefully admit its failure."); + form.destroy(); + }); + QUnit.test('basic domain field usage is ok', function (assert) { assert.expect(6); -- cgit v1.2.3