summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/basic_fields_tests.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2018-08-17 13:39:29 +0200
committerlen-odoo <35492570+len-odoo@users.noreply.github.com>2018-08-30 14:55:06 +0200
commit68332a0177990020f11b94317a6d3a81ff906d69 (patch)
tree7779d739bfb1ed4b8aea14ce607627f86802a7c6 /addons/web/static/tests/fields/basic_fields_tests.js
parent1ece9412be6ce30c46757a1a6a5025db62d9af85 (diff)
[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
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js27
1 files changed, 27 insertions, 0 deletions
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:
+ '<form>' +
+ '<field name="foo" widget="domain" options="{\'model\': \'partner\'}"/>' +
+ '<field name="int_field" invisible="1"/>' +
+ '</form>',
+ 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);