From e8f9bb683d958f0a7efa1e42a53633b72150c32f Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 5 May 2017 10:58:10 +0200 Subject: [FIX] web: DebouncedField: notify changes only when changed Before this rev., if you opened a form view with, e.g. a float field, that is unset, and then click on edit, then save, it actually saved the new value for the float field (being 0), whereas it shouldn't do any RPC as nothing changed. This is because the former code couldn't detect if the value "0" in the input is there because the field is still unset or if the user simply set it to 0. --- .../web/static/tests/fields/basic_fields_tests.js | 29 ++++++++++++++++++++++ 1 file changed, 29 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 a24944ed8a1..c1fb007b937 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -438,6 +438,35 @@ QUnit.module('basic_fields', { list.destroy(); }); + QUnit.test('do not trigger a field_changed if they have not changed', function (assert) { + assert.expect(2); + + this.data.partner.records[1].qux = undefined; + this.data.partner.records[1].int_field = undefined; + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'
' + + '' + + '' + + '' + + '' + + '
', + res_id: 2, + mockRPC: function (route, args) { + assert.step(args.method); + return this._super.apply(this, arguments); + } + }); + + form.$buttons.find('.o_form_button_edit').click(); + form.$buttons.find('.o_form_button_save').click(); + + assert.verifySteps(['read']); // should not have save as nothing changed + + form.destroy(); + }); QUnit.module('FieldEmail'); -- cgit v1.2.3