2017-06-02 37 views
4

我想重新定义一个默认的ListView函数,但它似乎不工作,我们没有得到进入功能体。任何建议?我如何包括(或扩展)从ListView的Odoo核心功能(例如Instance.web.ListView.extend)

instance.web.ListView.extend({ 
do_search: function (domain, context, group_by) { 
    console.log("We need to go deeper") // We aren't get here 
    this.current_min = 1; 
    this.groups.datagroup = new DataGroup(
     this, this.model, domain, context, group_by); 
    this.groups.datagroup.sort = this.dataset._sort; 
    if (_.isEmpty(group_by) && !context['group_by_no_leaf']) { 
     group_by = null; 
} 
    this.no_leaf = !!context['group_by_no_leaf']; 

    this.grouped = !!group_by; 

// Hide the pager in grouped mode 
    if (this.pager && this.grouped) { 
     this.pager.do_hide(); 
} 
    this.grouped = false; 
    return this.reload_content(); 
} 
})(); 

回答

2

您需要分配此列表视图监守扩展创造了新的构件,因此,您需要更改后,将其设置为相同的列表视图。 试试这个。

openerp.your_module_name = function(instance) { 
    instance.web.ListView = instance.web.ListView.extend({ 
     init : function() { 
        this._super.apply(this, arguments); 
     }, 
     do_search: function (domain, context, group_by) { 
        //Your Custom Code 
     }, 
    }); 
}; 
+1

它运作良好,谢谢! –

+1

不错的答案。也为我工作。谢谢你,先生。 –