How can I enable (or extend) the main Odoo function from a ListView (e.g. Instance.web.ListView.extend)

I am trying to override one of the default ListView functions, but it does not seem to work, and we do not fall into the function body. Any tips?

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();
}
})();
+4
source share
1 answer

You need to assign this list view because the extension creates a new widget, so you need to install it in the same list as after the changes. Try it.

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
         },
    });
};
+2
source

Source: https://habr.com/ru/post/1678432/


All Articles