title: Odoo 8 open treeview from wizard
body: <p>I have a wizard that research and add the result to a table and I created a treeview that read the items in this table. I want my wizard to open that treeview once the research is done but I can't find a way to redirect to a specific view from python. Anyone have an idea?</p>
  
  <p>My module is called <strong>sale_recherche_client_produit</strong></p>
  
  <p>All my files are at the root of my project folder</p>
  
  <p>My main python file (sale_recherche_client_produit_wizard.py)</p>
  
  <pre><code># -*- coding: utf-8 -*-
  from openerp import models, fields, api, tools, exceptions
  from openerp.exceptions import Warning
  import math, json, urllib
  
  
  class SaleRechercheClientProduitWizard(models.TransientModel):
      _name = "sale.order.line.search"
  
  products = fields.Many2one("product.template", string="Meubles", required=True)
  lieu = fields.Char(string="Lieu", required=False)
  distance = fields.Selection([
      ('10', "10km"),
      ('50', "50km"),
      ('100', "100km"),
      ('aucune', "Aucune limite"),
  ], default='50',string="Distance", required=True)
  
  @api.one
  def recherche(self):
      lieu = self.lieu
      distance = self.distance
      products = self.products
  
      clients = self.env["res.partner"].search([['is_company', '=', True], ['customer', '=', True]])
      clients_proches = []
  
      if (distance=="aucune"):
          for client in clients:
              clients_proches.append(client)
      else:
          if lieu :
              coordonees = geo_find(lieu)
              if coordonees:
                  lieu_latitude, lieu_longitude = coordonees
              else:
                  raise Warning('Veuillez entrer une adresse valide')
          else:
              raise Warning('Veuillez entrer une adresse')
  
          for client in clients:
              if client.partner_latitude and client.partner_longitude and (calculate_distance(client.partner_latitude, client.partner_longitude, lieu_latitude, lieu_longitude)) &lt;= float(distance):
                  clients_proches.append(client)
  
  
      if clients_proches:
          order_lines = []
          for client in clients_proches:
              lines = self.env["sale.order.line"].search([['order_partner_id', '=', client.id]])
              if lines:
                  for line in lines:
                      if line.product_id.id == products.id:
                          order_lines.append(line)
      else:
          raise Warning('Aucun résultat')
  
      if order_lines:
          self.env.cr.execute("DELETE FROM sale_order_line_result;")
          for order_line in order_lines:
              self.env["sale.order.line.result"].create({'sale_line_id': order_line.id})
  
          self.ensure_one()
          treeview_id = self.env.ref('sale_recherche_client_produit.sale_recherche_client_produit_tree_view').id
  
          return {
              'name': 'Résultats de la recherche',
              'type': 'ir.actions.act_window',
              'view_type': 'form',
              'view_mode': 'tree,form',
              'res_model': 'sale.order.line.result',
              'views': [(treeview_id, 'tree')],
              'view_id': treeview_id,
              'target': 'current',
          }
      else:
          raise Warning('Aucun résultat')
  
  
  # Pour trouver la distance entre deux latitudes/longitudes
  # explications de l'algorithme sur ce site
  # http://www.movable-type.co.uk/scripts/latlong.html
  
  def calculate_distance(lat1, lon1, lat2, lon2):
  R = 6371e3
  phi1 = math.radians(lat1)
  phi2 = math.radians(lat2)
  deltaPhi = math.radians(lat2-lat1)
  deltaLambda = math.radians(lon2-lon1)
  a = math.sin(deltaPhi/2) * math.sin(deltaPhi/2) + math.cos(phi1) * math.cos(phi2) * math.sin(deltaLambda/2) * math.sin(deltaLambda/2)
  c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
  d = (R * c) / 1000
  return d
  
  
  def geo_find(addr):
      url = 'https://maps.googleapis.com/maps/api/geocode/json?sensor=false&amp;key=AIzaSyAIX_OUi6dbQFMzxxvCfMtMiXG3nZBUV4I&amp;address='
      url += urllib.quote(addr.encode('utf8'))
  
  try:
      result = json.load(urllib.urlopen(url))
  except Exception, e:
      return 'Network error, Cannot contact geolocation servers. Please make sure that your internet connection is up and running (%s).' + e
  if result['status'] != 'OK':
      return None
  
  try:
      geo = result['results'][0]['geometry']['location']
      return float(geo['lat']), float(geo['lng'])
  except (KeyError, ValueError):
      return None
  </code></pre>
  
  <p>The xml file that goes with the main python file (sale_recherche_client_produit_wizard.xml)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;openerp&gt;
      &lt;data&gt;
  
          &lt;record model="ir.ui.view" id="sale_recherche_client_produit_wizard_form"&gt;
              &lt;field name="name"&gt;sale.recherche.client.produit.form&lt;/field&gt;
              &lt;field name="model"&gt;sale.order.line.search&lt;/field&gt;
              &lt;field name="type"&gt;form&lt;/field&gt;
              &lt;field name="arch" type="xml"&gt;
                  &lt;form string="Rechercher" version="8.0"&gt;
                      &lt;p&gt; Veuillez choisir une région et un produit. &lt;/p&gt;
                      &lt;group&gt;
                          &lt;field name="products"/&gt;
                      &lt;/group&gt;
                      &lt;group&gt;
                          &lt;field name="lieu" /&gt;
                          &lt;field name="distance"/&gt;
                      &lt;/group&gt;
                      &lt;button string="Rechercher" type="object" name="recherche"/&gt;
                      &lt;button string="Annuler" class="oe_highlight" special="cancel"/&gt;
                  &lt;/form&gt;
              &lt;/field&gt;
          &lt;/record&gt;
  
          &lt;record id="action_sale_recherche_client_produit" model="ir.actions.act_window"&gt;
                  &lt;field name="name"&gt;Recherche de clients&lt;/field&gt;
                  &lt;field name="res_model"&gt;sale.order.line.search&lt;/field&gt;
                  &lt;field name="view_type"&gt;form&lt;/field&gt;
                  &lt;field name="view_id" ref="sale_recherche_client_produit_wizard_form"/&gt;
                  &lt;field name="multi"&gt;True&lt;/field&gt;
                  &lt;field name="target"&gt;new&lt;/field&gt;
          &lt;/record&gt;
  
          &lt;menuitem action="action_sale_recherche_client_produit" id="menu_sale_recherche_client_produit" name="Recherche clients produits" parent="base.menu_sales"/&gt;
  
      &lt;/data&gt;
  &lt;/openerp&gt;
  </code></pre>
  
  <p>The treeview I want to open (sale_recherche_client_produit_tree.xml)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;openerp&gt;
      &lt;data&gt;
          &lt;record id="sale_recherche_client_produit_tree_view" model="ir.ui.view"&gt;
              &lt;field name="name"&gt;sale.recherche.client.produit.tree&lt;/field&gt;
              &lt;field name="model"&gt;sale.order.line.result&lt;/field&gt;
              &lt;field name="type"&gt;tree&lt;/field&gt;
              &lt;field eval="7" name="priority"/&gt;
              &lt;field name="arch" type="xml"&gt;
                  &lt;tree string="Recherche"&gt;
                      &lt;field name="client" string="Client"/&gt;
                      &lt;field name="ville" string="Ville"/&gt;
                      &lt;field name="produit" string="Produit"/&gt;
                      &lt;field name="qty" string="Quantité"/&gt;
                      &lt;field name="date" string="Date"/&gt;
                  &lt;/tree&gt;
              &lt;/field&gt;
          &lt;/record&gt;
      &lt;/data&gt;
  &lt;/openerp&gt;
  </code></pre>