From a51a5b70d3c78b65d32a9fa576dffa3d8a2af666 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 7 Sep 2018 08:26:12 +0200 Subject: [FIX] web: FieldDomain: reset field with a new domain Before this rev., there was a crash when a FieldDomain was reset with a new domain (e.g. coming from an onchange). For instance, it crashed in Email Marketing > create new Mass Mailing > select mailing lists. Introduced by 68332a01. opw-1882850 --- .../web/static/tests/fields/basic_fields_tests.js | 37 ++++++++++++++++++++++ 1 file changed, 37 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 4dd595cbfa0..fade0282f69 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -4521,6 +4521,43 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('domain field can be reset with a new domain (from onchange)', function (assert) { + assert.expect(2); + + this.data.partner.records[0].foo = '[]'; + this.data.partner.onchanges = { + display_name: function (obj) { + obj.foo = '[["id", "=", 1]]'; + }, + }; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: + '
' + + '' + + '' + + '', + res_id: 1, + viewOptions: { + mode: 'edit', + }, + }); + + assert.equal(form.$('.o_domain_show_selection_button').text().trim(), '5 record(s)', + "the domain being empty, there should be 5 records"); + + // update display_name to trigger the onchange and reset foo + form.$('.o_field_widget[name=display_name]').val('new value').trigger('input'); + + assert.equal(form.$('.o_domain_show_selection_button').text().trim(), '1 record(s)', + "the domain has changed, there should be only 1 record"); + + form.destroy(); + }); + QUnit.test('domain field: handle false domain as []', function (assert) { assert.expect(3); -- cgit v1.2.3