From 1b9baf1ac23aaddcac959292a05da6da0dbc1c7b Mon Sep 17 00:00:00 2001 From: Arthur Maniet Date: Mon, 4 Jan 2016 13:53:49 +0100 Subject: [FIX] barcode: value representation for scannable field float The value was stored as a string when it should have been a float. opw-665376 --- addons/barcodes/static/src/js/field_float_scannable.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'addons/barcodes/static/src/js/field_float_scannable.js') diff --git a/addons/barcodes/static/src/js/field_float_scannable.js b/addons/barcodes/static/src/js/field_float_scannable.js index 1a461f0048c..79022362251 100644 --- a/addons/barcodes/static/src/js/field_float_scannable.js +++ b/addons/barcodes/static/src/js/field_float_scannable.js @@ -2,6 +2,7 @@ odoo.define('barcodes.FieldFloatScannable', function(require) { "use strict"; var core = require('web.core'); +var formats = require('web.formats'); var form_widgets = require('web.form_widgets'); // Field in which the user can both type normally and scan barcodes @@ -14,6 +15,13 @@ var FieldFloatScannable = form_widgets.FieldFloat.extend({ 'keypress': 'simulateKeypress', }, + // Widget values are parsed according to the widget type. Since this widget is of type + // "FieldFloatScannable" and there is no parsing planned for this type, it defaults + // to outputting the value as a string. Hence the need to redefine parse_value + parse_value: function(val, def) { + return formats.parse_value(val, {type: "float"}, def); + }, + simulateKeypress: function (e) { var character = String.fromCharCode(e.which); var current_str = e.target.value; -- cgit v1.2.3