Search code examples
javascriptpythonodooodoo-12

How to return to home page upon clicking Cancel in a wizard in Odoo 12?


I am using Odoo 12's enterprise version code for customization and I need to redirect to the homepage (web#home) from a wizard upon clicking the cancel button. I searched a lot to find the menu_id or action which calls the homepage to return it from a python method, but I could not find it. Is there any way to do this or not? Below is my code in python file where I want to return the action or menu of the homepage:

def action_cancel(self):
        return {
            'name': _("Main Menu"),
            'type': 'ir.actions.client',
            'tag': 'reload',
        }

Solution

  • Simply you can use ir.actions.act_url

    Eg:

    def action_cancel(self):
       return {
          'type': 'ir.actions.act_url',
          'target': 'self',
          'url': '/home'
       }