From 7095c32f1cd17a86606e4137ece8baa3034fe74a Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 25 Aug 2017 12:12:42 +0200 Subject: [FIX] web: tests: correctly destroy view --- addons/web/static/tests/fields/basic_fields_tests.js | 2 ++ 1 file changed, 2 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 1f9e416223c..f851ad60115 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1241,6 +1241,8 @@ QUnit.module('basic_fields', { // Copying from a div tag with white-space:pre-wrap doesn't work in Firefox assert.strictEqual(form.$('[name="txt"]').prop("tagName").toLowerCase(), 'span', "the field contents should be surrounded by a span tag"); + + form.destroy(); }); QUnit.module('FieldBinary'); -- cgit v1.2.3 From 5149e18ec704df151c03d3b1e35d5f04328b89d3 Mon Sep 17 00:00:00 2001 From: Khoi Nguyen Date: Tue, 29 Aug 2017 10:59:25 +0200 Subject: [FIX] web: always display handle widget Before this commit, a list containing a handle widget would only display the handles associated with non-zero integer values. This is due to the fact that unset fields are hidden in Odoo, while a field is by default considered 'defined' if its value is truthy. We override the isSet method for the handle widget to always return true. This tells the handle widget that the associated integer value is always defined, thereby ensuring that the handle will always be shown. --- addons/web/static/tests/fields/basic_fields_tests.js | 18 ++++++++++++++++++ 1 file changed, 18 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 f851ad60115..984fa156d9c 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1578,6 +1578,24 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('handle widget with falsy values', function (assert) { + assert.expect(1); + + var list = createView({ + View: ListView, + model: 'partner', + data: this.data, + arch: '' + + '' + + '' + + '', + }); + + assert.strictEqual(list.$('.o_row_handle:visible').length, this.data.partner.records.length, + 'there should be a visible handle for each record'); + list.destroy(); + }); + QUnit.module('FieldDate'); -- cgit v1.2.3 From 4f61e7f0481fa2e2bfd806d92ea77f07b78d42de Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 29 Aug 2017 13:41:28 +0200 Subject: [FIX] web: WidgetDomain: don't crash on false domain Before this rev., when the value of a field with widget='domain' was false, the search_count RPC made to display the number of records matching the domain crashed, and the widget displayed that the domain was invalid. This rev. adds a fallback on [] when the domain is false. --- .../web/static/tests/fields/basic_fields_tests.js | 38 ++++++++++++++++++++++ 1 file changed, 38 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 984fa156d9c..c33cb8a4151 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -3757,6 +3757,44 @@ QUnit.module('basic_fields', { "field selector popover should contain 'Color index' field"); form.destroy(); }); + + QUnit.test('domain field: handle false domain as []', function (assert) { + assert.expect(2); + + this.data.partner.records[0].foo = false; + this.data.partner.fields.bar.type = "char"; + this.data.partner.records[0].bar = "product"; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: + '
' + + '' + + '' + + '' + + '' + + '' + + '' + + '
', + mockRPC: function (route, args) { + if (args.method === 'search_count') { + assert.deepEqual(args.args[0], [], "should send a valid domain"); + } + return this._super.apply(this, arguments); + }, + res_id: 1, + viewOptions: { + mode: 'edit', + }, + }); + + var $warning = form.$('.o_field_widget[name=foo] .text-warning'); + assert.strictEqual($warning.length, 0, "should not display that the domain is invalid"); + + form.destroy(); + }); }); }); }); -- cgit v1.2.3