5
votes

I want to reload a page in odoo on a click of a button. I tried this:

  • object_name.refresh()
  • return {'tag': 'reload'}

but it's not working.

How can I get it?

5

5 Answers

5
votes

add 'type': 'ir.actions.client' in your return like:

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

Return view on button click, for that you need to call method on button click and inside that method you need to write code like this,

@api.multi
def reload_page(self):
    model_obj = self.env['ir.model.data']
    data_id = model_obj._get_id('module_name', 'view_id')
    view_id = model_obj.browse(data_id).res_id
    return {
        'type': 'ir.actions.act_window',
        'name': _('String'),
        'res_model': 'model.name',
        'view_type' : 'tree',
        'view_mode' : 'form',
        'view_id' : view_id,
        'target' : 'current',
        'nodestroy' : True,
    }

Xml code for button,

<button type="object" name="reload_page" string="Reload Page" />
0
votes

you can try with the ActionManager extension which should be defined in the JS file within your module.

for Example : 'static/src/js/your_module_name.js'

put the below js code

openerp.your_module_name = 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.views[this.inner_widget.active_view].controller.reload();
           return $.when();
       },
   });
}

Call the action into button action

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

I hope my answer may help you :)

-1
votes

Just write "pass" inside function of button. Eg:

Def button_refresh():
    pass
-1
votes

Just try this, may help you

'res_model': 'your.model.to.reload',