Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Odoo Reload on button click

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?

like image 433
deepika bhojani Avatar asked Sep 27 '22 15:09

deepika bhojani


2 Answers

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

return {
      'type': 'ir.actions.client',
      'tag': 'reload',
}
like image 51
Rinaldi Avatar answered Oct 06 '22 00:10

Rinaldi


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" />
like image 23
Emipro Technologies Pvt. Ltd. Avatar answered Oct 06 '22 01:10

Emipro Technologies Pvt. Ltd.