From c5d5d7a0ff05d1664e50e5239e5b5efa77a032f6 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 31 Mar 2017 13:29:29 +0200 Subject: [FIX] web: monetary field was adding DOM at each rendering Before this commit, the `render` method of the monetary field added the and currency elements without removing the previous ones. As this was called on each related `onchange`, the DOM was growing at each of these changes. --- addons/web/static/test/fields/basic_fields_tests.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'addons/web/static/test/fields/basic_fields_tests.js') diff --git a/addons/web/static/test/fields/basic_fields_tests.js b/addons/web/static/test/fields/basic_fields_tests.js index 287134b43a1..8cea1900c7c 100644 --- a/addons/web/static/test/fields/basic_fields_tests.js +++ b/addons/web/static/test/fields/basic_fields_tests.js @@ -1332,12 +1332,17 @@ QUnit.module('basic_fields', { list.destroy(); }); - QUnit.test('monetary field with real monetary field in model', function (assert) { - assert.expect(2); + assert.expect(3); this.data.partner.fields.qux.type = "monetary"; + this.data.partner.onchanges = { + bar: function (obj) { + obj.qux = obj.bar ? 100 : obj.qux; + }, + }; + var form = createView({ View: FormView, model: 'partner', @@ -1346,6 +1351,7 @@ QUnit.module('basic_fields', { '' + '' + '' + + '' + '' + '', res_id: 5, @@ -1362,6 +1368,10 @@ QUnit.module('basic_fields', { assert.strictEqual(form.$('.o_form_field_monetary > input').val(), "9.10", "input value in edition should only contain the value, without the currency"); + form.$('input[type="checkbox"]').click(); // Change the field on which the monetary depends + assert.strictEqual(form.$('.o_form_field_monetary > input').length, 1, + "After the onchange, the monetary should not have been duplicated"); + form.destroy(); }); -- cgit v1.2.3