From b431f8eadcc871090544515e7c68439ded628f5d Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 22 Feb 2019 13:45:30 +0000 Subject: [PATCH] [FIX] barcodes, web: float scannable - Switch to French language - Go to Inventory > Inventory Adjustment - Launch an adjustment The field 'Real Quantity' doesn't follow the float formatting. This is because the widget is set as `field_float_scannable`, which is not recognized by the formatting function. Since the widget descriptor has priority over the type descriptor, we must explicitly take this widget into account, on top of adding the `format_value` method. opw-1940884 closes odoo/odoo#31366 --- addons/barcodes/static/src/js/field_float_scannable.js | 4 ++++ addons/web/static/src/js/framework/formats.js | 2 ++ 2 files changed, 6 insertions(+) diff --git a/addons/barcodes/static/src/js/field_float_scannable.js b/addons/barcodes/static/src/js/field_float_scannable.js index 801cf32b5e2..5497a488c79 100644 --- a/addons/barcodes/static/src/js/field_float_scannable.js +++ b/addons/barcodes/static/src/js/field_float_scannable.js @@ -22,6 +22,10 @@ var FieldFloatScannable = form_widgets.FieldFloat.extend({ return formats.parse_value(val, {type: "float"}, def); }, + format_value: function(val, def) { + return formats.format_value(val, {type: "float"}, def); + }, + simulateKeypress: function (e) { /* only simulate a keypress if it has been previously prevented */ if (e.originalEvent.dispatched_by_barcode_reader !== true) { diff --git a/addons/web/static/src/js/framework/formats.js b/addons/web/static/src/js/framework/formats.js index c4d001a12e1..6d8e94d6541 100644 --- a/addons/web/static/src/js/framework/formats.js +++ b/addons/web/static/src/js/framework/formats.js @@ -47,6 +47,7 @@ function format_value (value, descriptor, value_if_empty) { _.str.sprintf('%d', value)); case 'monetary': case 'float': + case 'field_float_scannable': var digits = descriptor.digits ? descriptor.digits : [69,2]; digits = typeof digits === "string" ? py.eval(digits) : digits; var precision = digits[1]; @@ -135,6 +136,7 @@ function parse_value (value, descriptor, value_if_empty) { return tmp; case 'monetary': case 'float': + case 'field_float_scannable': var tmp2 = value; do { tmp = tmp2;