覆盖自定义模块odoo 11中的pivot-view_render函数



我想覆盖&quot_render:函数((";函数,但不在自定义模块中工作。以下是我在自定义模块中实现的代码:-

odoo.define('MY_CUSTOM_MODULE_NAME.renderer', function (require) {
"use strict";
var PivotRenderer = require('web.PivotRenderer');
var field_utils = require('web.field_utils');
var core = require('web.core');
var _t = core._t;
PivotRenderer.include({
init: function(parent, state, params) {
this._super.apply(this, arguments);
},
_render: function () {
if (!this._hasContent()) {
// display the nocontent helper
this.replaceElement(QWeb.render('PivotView.nodata'));
return this._super.apply(this, arguments);
}
if (!this.$el.is('table')) {
// coming from the no content helper, so the root element has to be
// re-rendered before rendering and appending its content
this.renderElement();
}
var $fragment = $(document.createDocumentFragment());
var $table = $('<table>').appendTo($fragment);
var $thead = $('<thead>').appendTo($table).addClass("CLASS_NAME");
var $tbody = $('<tbody>').appendTo($table);
var nbr_measures = this.state.measures.length;
var nbrCols = (this.state.mainColWidth === 1) ?
nbr_measures :
(this.state.mainColWidth + 1) * nbr_measures;
for (var i=0; i < nbrCols + 1; i++) {
$table.prepend($('<col>'));
}
this._renderHeaders($thead, this.state.headers);
this._renderRows($tbody, this.state.rows);
// todo: make sure the next line does something
$table.find('.o_pivot_header_cell_opened,.o_pivot_header_cell_closed').tooltip();
this.$el.html($table.contents());
return this._super.apply(this, arguments);
},
});
});

在上面的文章中,我想在标题中添加一个类,用于调用我的自定义css"var$thead=$(''(.appendTo($table(.addClass("CLASS_NAME"(">使用此语法,但它没有反映在我的自定义模块中。不过,为了测试,我已经在默认的web模块中实现了相同的类,它运行得很好。问题出现在自定义模块中。

那么如何解决这个问题呢?有没有其他方法可以上课,或者我做得不对?

var$thead=$(''(.addClass("class_NAME"(.appendTo($table(;

这对我来说是可行的。你可以试试。

最新更新