Yenthe666 / Odoo_Samples

This repository contains samples with Odoo code
GNU Affero General Public License v3.0
242 stars 306 forks source link

Web auto refresh module on V9 #5

Open effelle opened 8 years ago

effelle commented 8 years ago

@Yenthe666 ,

I've read your reply on your blog just now. Sorry for the HUGE delay! How did you manage to add auto update to V9? Did you edit

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

F.

Yenthe666 commented 8 years ago

Hi @effelle I poked around on Odoo and looked through the functions to find a correct option to refresh the View in Odoo 9. Haven't edited the one you linked.

effelle commented 8 years ago

Is there an option? Where?

Yenthe666 commented 8 years ago

@effelle an example:

var refresh_page = function(view) {
    setInterval(function() {
        var active_view = view.action_manager.inner_widget.active_view;
        if (typeof(active_view) != 'undefined'){
            try {
                var controller = view.action_manager.inner_widget.active_view.controller;
                var action = view.action_manager.inner_widget.action;
                if (String(action.view_id).match(/Your view title/)) {
                    controller.reload();
                }
            } catch (e) {
                alert(e);
            }
        }
    }, 5000);
}

openerp.web.WebClient.include({
    start: function() {
        //alert("Start");
        this._super();
        refresh_page(this);
    },
})

This will reload the view once every 5 seconds.

effelle commented 8 years ago

Ok, this is a little confusing. You are using this on a single web module or did you add @ global level? BEcause this code should work on V8 too. Did you use this code on a stock module? Have you add an example on Odoo_sample? Thanks.

Yenthe666 commented 8 years ago

@effelle I'm using this in a custom developed module to refresh one treeview. This has nothing to do with the stock module or anything.

effelle commented 8 years ago

Got it. I'll test on one of mine on V9 on the next testing. Thanks for now!

prakashjain commented 6 years ago

Hi Yenthe,

I have same requirements in version 9 custom module tree view auto reload particular interval. Your code is working fine, but it reloads both form and tree view, in form view loss data, is any away auto reload prevent in form view and apply only in tree view. Thanks