odoo-13.0/addons/web/static/src/js/fields/field_utils.js
/**
 * Returns a string representing an many2one.  If the value is false, then we
 * return an empty string.  Note that it accepts two types of input parameters:
 * an array, in that case we assume that the many2one value is of the form
 * [id, nameget], and we return the nameget, or it can be an object, and in that
 * case, we assume that it is a record datapoint from a BasicModel.
 *
 * @param {Array|Object|false} value
 * @param {Object} [field]
 *        a description of the field (note: this parameter is ignored)
 * @param {Object} [options] additional options
 * @param {boolean} [options.escape=false] if true, escapes the formatted value
 * @returns {string}
 */
Returns a string representing an many2one.  If the value is false, then we
return an empty string.  Note that it accepts two types of input parameters:
an array, in that case we assume that the many2one value is of the form
[id, nameget], and we return the nameget, or it can be an object, and in that
case, we assume that it is a record datapoint from a BasicModel.


Returns a string representing an many2one . If the value is false then we return an empty string . Note that it accepts two types of input parameters : an array in that case we assume that the many2one value is of the form [ id nameget ] and we return the nameget or it can be an object and in that case we assume that it is a record datapoint from a BasicModel .
function formatMany2one(value, field, options) {
    if (!value) {
        value = '';
    } else if (_.isArray(value)) {
        value = value[1];
    } else {
        while (value.data) {
            value = value.data.display_name || '';
        }
    }
    if (options && options.escape) {
        value = _.escape(value);
    }
    return value;
}
function formatMany2one ( value , field , options ) { if ( ! value ) { value = '' ; } else if ( _ . isArray ( value ) ) { value = value [ 1 ] ; } else { while ( value . data ) { value = value . data . display_name || '' ; } } if ( options && options . escape ) { value = _ . escape ( value ) ; } return value ; }
Returns a string representing an many2one.
Returns a string representing an many2one .
// value is a pair [id, nameget] // value is a datapoint, so we read its display_name field, which // may in turn be a datapoint (if the name field is a many2one)