odoo-13.0/addons/web/static/src/js/fields/field_utils.js
/**
 * Returns a string representing a float.  The result takes into account the
 * user settings (to display the correct decimal separator).
 *
 * @param {float|false} value the value that should be formatted
 * @param {Object} [field] a description of the field (returned by fields_get
 *   for example).  It may contain a description of the number of digits that
 *   should be used.
 * @param {Object} [options] additional options to override the values in the
 *   python description of the field.
 * @param {integer[]} [options.digits] the number of digits that should be used,
 *   instead of the default digits precision in the field.
 * @param {function} [options.humanReadable] if returns true,
 *   formatFloat acts like utils.human_number
 * @returns {string}
 */
Returns a string representing a float.  The result takes into account the
user settings (to display the correct decimal separator).

@param {float|false} value the value that should be formatted
@param {Object} [field] a description of the field (returned by fields_get
for example).  It may contain a description of the number of digits that
should be used.
@param {Object} [options] additional options to override the values in the
python description of the field.
@param {integer[]} [options.digits] the number of digits that should be used,
instead of the default digits precision in the field.
@param {function} [options.humanReadable] if returns true,
formatFloat acts like utils.human_number
@returns {string}
Returns a string representing a float . The result takes into account the user settings ( to display the correct decimal separator ) . @param { float|false } value the value that should be formatted @param { Object } [ field ] a description of the field ( returned by fields_get for example ) . It may contain a description of the number of digits that should be used . @param { Object } [ options ] additional options to override the values in the python description of the field . @param { integer [] } [ options . digits ] the number of digits that should be used instead of the default digits precision in the field . @param { function } [ options . humanReadable ] if returns true formatFloat acts like utils . human_number @returns { string }
function formatFloat(value, field, options) {
    options = options || {};
    if (value === false) {
        return "";
    }
    if (options.humanReadable && options.humanReadable(value)) {
        return utils.human_number(value, options.decimals, options.minDigits, options.formatterCallback);
    }
    var l10n = core._t.database.parameters;
    var precision;
    if (options.digits) {
        precision = options.digits[1];
    } else if (field && field.digits) {
        precision = field.digits[1];
    } else {
        precision = 2;
    }
    var formatted = _.str.sprintf('%.' + precision + 'f', value || 0).split('.');
    formatted[0] = utils.insert_thousand_seps(formatted[0]);
    return formatted.join(l10n.decimal_point);
}
function formatFloat ( value , field , options ) { options = options || { } ; if ( value === false ) { return "" ; } if ( options . humanReadable && options . humanReadable ( value ) ) { return utils . human_number ( value , options . decimals , options . minDigits , options . formatterCallback ) ; } var l10n = core . _t . database . parameters ; var precision ; if ( options . digits ) { precision = options . digits [ 1 ] ; } else if ( field && field . digits ) { precision = field . digits [ 1 ] ; } else { precision = 2 ; } var formatted = _ . str . sprintf ( '%.' + precision + 'f' , value || 0 ) . split ( '.' ) ; formatted [ 0 ] = utils . insert_thousand_seps ( formatted [ 0 ] ) ; return formatted . join ( l10n . decimal_point ) ; }
Returns a string representing a float.
Returns a string representing a float .