Reload kanban view after a wizards closes in ODOO 8

2.3k views Asked by At

I am trying to execute an action after a wizard action is performed, i want to reload a kanban:

Python code:

return {'type': 'ir.actions.act_close_wizard_and_reload_view', } 

Javascript code: (taken from the forum, i think for version 7)

openerp.bmwe_crm = function(instance, local) {
    instance.web.ActionManager = instance.web.ActionManager.extend({
        ir_actions_act_close_wizard_and_reload_view: function (action,options) {
            if (!this.dialog) {
                options.on_close();
            }
            this.dialog_stop();
            this.inner_widget.views[this.inner_widget.active_view].controller.reload();
                        return $.when();
            }
    });
    } 

All this from a forum about 7.0 version, but i am using 8.0 and it does not seems to work. I've even trying executing a default action:

return { 'type': 'ir.actions.client', 'tag': 'reload'} 

Does not reload the page neither

4

There are 4 answers

0
Atul Arvind On

To reload a view you can return a view like below. It will return & reload the desired view when wizard closes.

ir_model_data = self.env['ir.model.data']
view_id = ir_model_data.get_object_reference('module_name', 'view_name')[1]

return {
    'name': 'view name',
    'view_type': 'form',
    'view_mode': 'kanban,tree,form',
    'res_model': 'your.model.to.reload',
    'view_id': view_id,
    'context': self._context,
    'type': 'ir.actions.act_window',
    'target': 'current',
}
0
alacret On

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();
    });
};

DONE!

0
raBinn On

In my odoo this solution doesn't work...

[ironic mode on] It is one of those things I love about Odoo [ironic mode off]

To other person than the proposal solution doesn't work and need one solution, try this:

return {
            'type': 'ir.actions.client',
            'tag': 'reload',  
        }

where you return value, or close the wizard, put this code.

Seriously , good luck.

0
Thu Ra On

I can solved this right now as follow

static/src/js/your_module_name.js

openerp.yout_module = function (instance) {
    instance.web.ActionManager = instance.web.ActionManager.extend({
        ir_actions_act_close_wizard_and_reload_view: function (action, options) {
            if (!this.dialog) {
                options.on_close();
            }
            this.dialog_stop();
            this.inner_widget.active_view.controller.reload();
            return $.when();
        },
    });
}

views/your_module_name.xml

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>
        <template id="assets_backend" name="your_module_name assets" inherit_id="web.assets_backend">
        <xpath expr="." position="inside">
            <script type="text/javascript" src="/your_module_name/static/src/js/your_js_file_name.js"></script>
        </xpath>
        </template>
    </data>
</openerp>

wizard/your_wizard.py

return { 'type' :  'ir.actions.act_close_wizard_and_reload_view' }

reference1

reference2

above the references, they are using

this.inner_widget.views[this.inner_widget.active_view].controller.reload();

but it is not working in v8. So, I modified it to

this.inner_widget.active_view.controller.reload();

Now, it is working.