爲了能夠在列表視圖中的HTML,你需要重寫方法_format()如下(爲Odoo V10)
JS
odoo.define('html_in_tree_field.web_ext', function (require) {
"use strict";
var Listview = require('web.ListView');
var formats = require('web.formats');
Listview.Column.include({
_format: function (row_data, options) {
// Removed _.escape() function to display html content.
// Before : return _.escape(formats.format_value(row_data[this.id].value, this, options.value_if_empty));
return formats.format_value(row_data[this.id].value, this, options.value_if_empty);
}
});
});
XML上面添加JS。
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets_ext" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/html_in_tree_field/static/src/js/web_ext.js"></script>
</xpath>
</template>
</odoo>
__manifest__.py
{
...
...
'data': [
...
'views/above_xml_filename.xml',
],
....
}
能否請您加入問題的樹狀視圖? –
@VikiChavada我加我的榜樣! –