'prepare the backend url to the given action, or to the given module view.
:param action_xml_id : the xml id of the action to redirect to
:param view_type : the view type to display when redirecting (form, kanban, list, ...)
:param module_name : the name of the module to display (if action_xml_id is \'open_module_tree\'), or
to redirect to if the action is not found.
:returns url : the url to the correct page'

@api.model
def prepare_backend_url(self, action_xml_id, view_type='list', module_name=None):

    params = dict(view_type=view_type)
    action = self.env.ref(action_xml_id, False)
    if action:
        params['action'] = action.id
    else:
        params['model'] = 'ir.module.module'
    if module_name:
        module = self.env['ir.module.module'].sudo().search([('name', '=', module_name)], limit=1)
        if module:
            params['id'] = module.id
        else:
            return '#show_enterprise'
    return ('/web#%s' % (urlencode(params),))
