使用javascript隐藏OpenERP模块中的字段



我只想隐藏我添加到模型sales.order.line并将其添加到sales.order.form的字段。我尝试了以下代码:

openerp.sales_extra  = function(instance){
// module code goes here
console.log('My module has been initialized');
var MODELS_TO_HIDE = ['sale.order.line'];
openerp.web.FormView.include({
    start: function() {
    // on_loaded: function(data) {
        var self = this;
        var ret = this._super.apply(this, arguments);
        var res_model = this.dataset.model;
        if ($.inArray(res_model, MODELS_TO_HIDE) != -1) {
            //this.$element.find('add_to_inv').remove();
            this.$element.find('add_to_inv').hide();//this the field which i want to hide
        };
        return ret;
    },
});

};

但我得到以下错误:

Uncaught TypeError: Cannot read property 'include' of undefined 

另一个问题是,如果这个字段在我的OpenERP模块中是布尔型的,如何知道它是否在js中检查过?

从OpenERP 7.0开始,对于初学者,您必须使用

instance.web.FormView = instance.web.FormView.extend({

而不是

openerp.web.FormView.include({

这只是一道开胃菜。

最新更新