Odoo Reload on button click

I want to reload a page with one click on one button. I've tried this:

  • object_name.refresh()

  • return {'tag': 'reload'}

but it doesn't work.

How can I get it?

+3


source to share


5 answers


The returned image when the button is clicked, for this you need to call the method when the button is clicked and inside this 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 the button,

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

      

+1


source


Just write "pass" inside the button function. For example:



Def button_refresh():
    pass

      

0


source


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

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

      

enter 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 action to button action

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

      

Hope my answer can help you :)

0


source


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

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

      

0


source


Just try this may help you

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

-1


source







All Articles