From 8859d25bc5b719734b7d02bc26adfd38dca79e56 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 15 Jun 2017 12:37:42 +0200 Subject: [FIX] web: FieldWidgets: use correct format/parse functions Field widgets must format and parse values according to the widget type, not to the field type. For example, if a monetary field is inserted in a form view with widget="float", the field's value must be formatted with the float formatter, not the montetary one. This wasn't the case before this rev. --- .../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 4b850b26d34..a2d0c100fd8 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -536,6 +536,35 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('float widget on monetary field', function (assert) { + assert.expect(1); + + this.data.partner.fields.monetary = {string: "Monetary", type: 'monetary'}; + this.data.partner.records[0].monetary = 9.99; + this.data.partner.records[0].currency_id = 1; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'
' + + '' + + '' + + '' + + '' + + '
', + res_id: 1, + session: { + currencies: _.indexBy(this.data.currency.records, 'id'), + }, + }); + + assert.strictEqual(form.$('.o_field_widget[name=monetary]').text(), '9.99', + 'value should be correctly formatted (with the float formatter)'); + + form.destroy(); + }); + QUnit.module('FieldEmail'); QUnit.test('email field in form view', function (assert) { -- cgit v1.2.3