[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
This commit is contained in:
Nicolas Martinelli
2019-02-22 13:45:30 +00:00
parent 264a047a8a
commit b431f8eadc
2 changed files with 6 additions and 0 deletions
@@ -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) {
@@ -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;