This question has been flagged
6 Replies
10212 Views

I would like to customize the number of items a kanban view shows before the user has to click the 'show more' button. In addons/web_kanban/static/src/js/kanban.js there is the following snippet of code:

 

instance.web_kanban.KanbanView = instance.web.View.extend({
    template: "KanbanView",

    ...
    init: function (parent, dataset, view_id, options) {
        this._super(parent, dataset, view_id, options);
        ...
        this.limit = options.limit || 40;
        ...
    },

Is there any way I can access the options variable from a custom module and set/override the limit value there?

This post https://www.odoo.com/forum/help-1/question/how-to-show-more-than-40-items-in-kanban-view-25752 provides a solution for setting the number of items, but it involves hardcoding the value in the original js file, but that's a bit tedious to maintain in the long run.

 

Avatar
Discard
Best Answer

Gary's problem is related I get the exact same thing when I add this code. From the looks of it for a custom view the options.limit can be overridden, so if you do not want this globally you could add this attribute to the existing view. I have tried this, but I am so far unsuccessful. I have tried adding options="{'limit': 80}" to many places in the xml and I tried adding the options parameter to the python that renders my action to no avail.


UPDATE: <kanban limit="2000"> now works in version 9, this is very recent code update as the code that makes this work did not exist in my dev environment but did in my test environment so update if it does not work for you.

Avatar
Discard
Best Answer

Indeed, the best option is to create your own js file inside your custom module. Once you do that, this should be the code to override the options for that instance:

    openerp.your_mod = function(instance, local) {
 
        instance.web_kanban.KanbanView = instance.web_kanban.KanbanView.extend({
            init: function (parent, dataset, view_id, options) {
                if (dataset._model.name == 'your_mod.object') { 
                    options.limit = 12;    //Imposed limit for my particular object
                }
                this._super(parent, dataset, view_id, options);
        }
    });
    instance.web.views.add('kanban_your_mod_limit', 'instance.your_mod.KanbanView');

Avatar
Discard

When I try this code, I get the following error in my browser Console. Any idea how to debug this further? boot.js:195 error: Some modules could not be started Failed modules: ["web.web_client"] Non loaded modules: ["base.apps", "im_odoo_support.OdooSupport", "__job1", "mail.chat_client_action", "mail.ChatComposer", "mail.chat_manager", "mail.Chatter", "mail.systray", "mail.window_manager", "mail_tip.mail_tip", "web.planner", "web_settings_dashboard"]

I can't really tell. Doesn't seem to be related to the piece of code above. Try posting a separate Question to get a broader attention from all experts. Also, make sure to put as much context as possible (excerpts of code if possible)

My kanban view is overloaded by boxes ;) So i need some solution as well ;) In my module which will be used to move whole locations from one place to another i would like to limit the amount of boxes to for example 4 kanban columns. With my over 500 locations i should save a lot of time. Now when I have to refresh it takes a minute before anything appears on the screen :( Once I manage to add a limit of columns it should be much quicker :)

The kanban columns (or lanes) are a whole different story I'm afraid. And tackling this via Javascript like the example above could turn out to be much more complicated. As you might notice, there is a prebuilt "options.limit" variable that already does the heavy lifting for the original question here... so it was a matter of overwriting it at some specific point. But I don't think there is such a thing for the number of columns/lanes. Maybe you should simply resort to 'domains' on the server side (python and xml). You could easily specify which 4 locations you want to display in your Window Action xml definition (something like: "[('location_id','in',[3,6,11,20])]"), which would guarantee you that only those 4 columns/lanes will be displayed (assuming your view is grouped by location_id of course). If you want to do something more sophisticated, you could resort to a wizard that somehow will dynamically determine which 4 locations get to be displayed, and call the Window Action via a python return (with the dynamically constructed domain therein)