6

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?

Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
deepika bhojani
  • 71
  • 1
  • 1
  • 4

5 Answers5

7

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

return {
      'type': 'ir.actions.client',
      'tag': 'reload',
}
Kenly
  • 24,317
  • 7
  • 44
  • 60
Rinaldi
  • 260
  • 3
  • 9
1

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

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 :)

DASADIYA CHAITANYA
  • 2,850
  • 3
  • 18
  • 41
-1

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

Def button_refresh():
    pass
Tintumon M
  • 1,156
  • 2
  • 14
  • 36
-1

Just try this, may help you

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

Jeenit khatri
  • 318
  • 4
  • 19