[FIX] web: list: do not escape cell titles

Task 2046921

closes odoo/odoo#41251

X-original-commit: d81cadc1a133117b4d692d2a7019e0100d8e411c
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Aaron Bohy
2019-12-03 08:55:11 +00:00
parent bde09810c7
commit ef2d4f6640
2 changed files with 28 additions and 5 deletions
@@ -434,17 +434,22 @@ var ListRenderer = BasicRenderer.extend({
var $el = this._renderFieldWidget(node, record, _.pick(options, 'mode'));
return $td.append($el);
}
this._handleAttributes($td, node);
var name = node.attrs.name;
var field = this.state.fields[name];
var value = record.data[name];
var formattedValue = field_utils.format[field.type](value, field, {
data: record.data,
var formatter = field_utils.format[field.type];
var formatOptions = {
escape: true,
data: record.data,
isPassword: 'password' in node.attrs,
digits: node.attrs.digits && JSON.parse(node.attrs.digits),
});
this._handleAttributes($td, node);
var title = field.type !== 'boolean' ? formattedValue : '';
};
var formattedValue = formatter(value, field, formatOptions);
var title = '';
if (field.type !== 'boolean') {
title = formatter(value, field, _.extend(formatOptions, {escape: false}));
}
return $td.html(formattedValue).attr('title', title);
},
/**
@@ -315,6 +315,24 @@ QUnit.module('Views', {
list.destroy();
});
QUnit.test('field titles are not escaped', async function (assert) {
assert.expect(2);
this.data.foo.records[0].foo = '<div>Hello</div>';
const list = await createView({
View: ListView,
model: 'foo',
data: this.data,
arch: '<tree><field name="foo"/></tree>',
});
assert.strictEqual(list.$('tbody tr:first .o_data_cell').text(), "<div>Hello</div>");
assert.strictEqual(list.$('tbody tr:first .o_data_cell').attr('title'), "<div>Hello</div>");
list.destroy();
});
QUnit.test('record-depending invisible lines are correctly aligned', async function (assert) {
assert.expect(4);