[FIX] web: ListView: format footer values
Before this rev., the aggregates values displayed in the footer of list views were formatted according to the field type, and the field's widget was ignored, whereas it should be used by default. For instance, if the 'float_time' widget is set on a float field, the sum should be formatted as FloatTime as well. Closes #22724.
This commit is contained in:
@@ -204,9 +204,11 @@ var ListRenderer = BasicRenderer.extend({
|
||||
var field = self.state.fields[column.attrs.name];
|
||||
var value = aggregateValues[column.attrs.name].value;
|
||||
var help = aggregateValues[column.attrs.name].help;
|
||||
var formattedValue = field_utils.format[field.type](value, field, {
|
||||
escape: true,
|
||||
});
|
||||
var formatFunc = field_utils.format[column.attrs.widget];
|
||||
if (!formatFunc) {
|
||||
formatFunc = field_utils.format[field.type];
|
||||
}
|
||||
var formattedValue = formatFunc(value, field, {escape: true});
|
||||
$cell.addClass('o_list_number').attr('title', help).html(formattedValue);
|
||||
}
|
||||
return $cell;
|
||||
|
||||
@@ -694,6 +694,25 @@ QUnit.module('Views', {
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('aggregates are formatted according to field widget', function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var list = createView({
|
||||
View: ListView,
|
||||
model: 'foo',
|
||||
data: this.data,
|
||||
arch: '<tree>' +
|
||||
'<field name="foo"/>' +
|
||||
'<field name="qux" widget="float_time" sum="Sum"/>' +
|
||||
'</tree>',
|
||||
});
|
||||
|
||||
assert.strictEqual(list.$('tfoot td:nth(2)').text(), '19:24',
|
||||
"total should be formatted as a float_time");
|
||||
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('groups can be sorted on aggregates', function (assert) {
|
||||
assert.expect(10);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user