From 1bbb7d62410d0fef9304c32b62a8aef032f97af8 Mon Sep 17 00:00:00 2001 From: Khoi Nguyen Date: Tue, 3 Oct 2017 16:52:08 +0200 Subject: [FIX] web: clear input on clicking 'Create and Edit' from many2one fields We clear the input field when clicking 'Create and Edit' to ensure that the field is empty if the user chooses to cancel the record creation. If a record is indeed created, then the field value will still be updated. --- addons/web/static/tests/fields/relational_fields_tests.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'addons/web/static/tests/fields/relational_fields_tests.js') diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index 5325132c09d..cfa6726f429 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -1489,7 +1489,7 @@ QUnit.module('relational_fields', { QUnit.test('pressing ENTER on a \'no_quick_create\' many2one should not trigger M2ODialog', function (assert) { var done = assert.async(); - assert.expect(1); + assert.expect(2); var M2O_DELAY = relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY; relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = 0; @@ -1527,6 +1527,10 @@ QUnit.module('relational_fields', { $input.blur(); assert.strictEqual($('.modal').length, 1, "should have one modal in body"); + // Check that discarding clears $input + $('.modal .o_form_button_cancel').click(); + assert.strictEqual($input.val(), '', + "the field should be empty"); form.destroy(); relationalFields.FieldMany2One.prototype.AUTOCOMPLETE_DELAY = M2O_DELAY; done(); -- cgit v1.2.3