This question has been flagged
2 Replies
11262 Views

currently the auto refresh in action window definition does not work for kanban view (per study further, auto refresh even does not work for web, only works for GUI), is there any other way around? Kanban view to be auto refreshed such as new task and task status change is more important.

there is web notification module by anybox which is of great help, https://bitbucket.org/anybox/web_notification/src, now I know that I can use the existing bus mechanism to trigger and update the webpage based on changed captured, I can now broadcast the chagne message (to certain channel) from server side by the following lines

@api.one
    def create(vals, context=None):
        bus = self.env['bus.bus']
        message = {
            'subject': 'xx',
            'body': 'xx',
"""         'user_ids': [(4, x.id) for x in self],  """
            'mode': 'notify',
        }

but I have no idea on javascript side, how to access the current action manager or kanban view, then calling the re_load or something simliar to trigger the actual refresh!

I tried the following on javascript side:

(function() {
    openerp.web.WebClient.include({
        declare_bus_channel: function() {
            this._super();
            var self = this,
                channel = 'xx';
            this.bus_on(channel, function(message) {
                openerp.webclient.action_manager.start();
                self.do_notify(message.subject,
                                       message.body,
                                       message.sticky);
            });
            this.add_bus_channel(channel);
        },
    });
})();

but unfortunately failed. anyone can help to guide me by sample code or sample reference module?

Many thanks.

P.S Actually it will be very help to know in customized module how to manipulate the existing web component! in essence this is about the webclient object hierarchy.

Avatar
Discard
Author Best Answer

there is new module released

 https://github.com/szufisher/web/tree/8.0/web_auto_refresh

Avatar
Discard
Best Answer


DISCALIMER: Not the best FIX, but it's a FIX.

NOTE: In teory odoo 8 web client engine must execute the Action that the Wizards returns in the python code function. This works in all views, except in Kanban views. So this is the workaround:

In the server, create a message in the odoo bus, every time you want to notify something happends:

            bus = self.env['bus.bus']
            message = {
                'subject': '',
                'body': 'Appointment Set',
                'mode': 'notify',
            }
            bus.sendone('<CHANNEL-NAME>', message)

Then, in the frontend you must listen for a message on this channel:

First, register the channel (With out this, it wouldn't work)

    openerp.bmwe_crm = function(instance, local) {
        var bus = instance.bus.bus;
        bus.add_channel("<CHANNEL-NAME>");   
        });
    };

Second, reload the kanban when something happend in the channel:

    openerp.bmwe_crm = function(instance, local) {
        var bus = instance.bus.bus;
        bus.add_channel("<CHANNEL-NAME>");
        instance.bus.bus.on("notification", instance, function(notification){
            instance.client.action_manager.inner_widget.views["kanban"].controller.do_reload();
        });
    };

Avatar
Discard