title: Odoo: Two selection fields, second selection depends on the first selected value
body: <p>I have a model with two selection fields. In the first selection field the user chooses a project, and in second the user chooses a tranche, depends on the selected first field. (for one project, we have many tranche)
  I use this declaration to my function:</p>
  
  <pre class="lang-py prettyprint-override"><code> @api.multi
   @api.onchange('project')
   def _get_tranche(self):
       print res
       return res`
  </code></pre>
  
  <p>If I'll print in console the result of returned value is correct, and I have exactly what I search, but in the view, the second field value does not displays computed values to choose after setting the second field value. 
  Is there any method to make it work properly?</p>
  
  <p>This is my code:</p>
  
  <pre class="lang-py prettyprint-override"><code>@api.model
  def _get_project(self):
  
      values = {'$top' : 100,
              '$filter' : "'name==:1&amp;&amp;parent==null'",
              '$params' : '\'["*"]\'' }
      response = requests.get('http://localhost:8081/rest/Project/name',
                              auth=('admin', 'admin'),
                              params=values)
      data = response.json()
      res = []
      for record in data['__ENTITIES']:
          res.append((record['__KEY'], record['name']))
      return res
  
  @property
  def ret_value(self):
      return self.project
  
  @api.multi
  @api.onchange('project')
  def _get_tranche(self):
          if self.ret_value == False:
              return []
  
          values = {'$top' : 100,
                  '$filter' : "'parent.ID==:1'",
                  '$params' : '\'[' + self.ret_value + ']\'' }
          response = requests.get('http://localhost:8081/rest/Project/name',
                                  auth=('admin', 'admin'),
                                  params=values)
          data = response.json()
          res = []
          for record in data['__ENTITIES']:
              res.append((record['__KEY'], record['name']))
          print res
          return res
  
  _columns = {
      'name': fields.char("Name", required=True),
  
      'description' : fields.text(),
  
      'project' :fields.selection(selection=_get_project, string="Project"),
      'tranche' : fields.selection(selection=_get_tranche, string="Tranche"),
  }
  </code></pre>
  
  <p>NB: a tranche is a project with parent_id (not null) = id of a project, I need do the following: when I select a project X from the first field selection "project", I can select the tranches of this project (project with parent_id=X) from the second field selection "tranche" what I can't understand is the result of print in the console is correct, but in the view the field tranche is empty??!!</p>
  
  <p>Now I am trying this:</p>
  
  <pre><code>        _columns = {
      'name': fields.char("Name", required=True),
  
      'description' : fields.text(),
  
      'project' :fields.selection(selection=_get_project, string="Project"),
      'tranche' : fields.selection(selection=_get_tranche,
   string="Tranche", compute='_return_tranche'),
   }
  @api.depends('project')
  def _return_tranche(self):
          if self.ret_value == False:
              self.tranche = []
              return
          values = {'$top' : 100,
                      '$filter' : "'parent.ID==:1'",
                      '$params' : '\'[' + self.ret_value + ']\'' }
          response = requests.get('http://localhost:8081/rest/Project/name',
                                  auth=('admin', 'admin'),
                                  params=values)
          data = response.json()
          res = []
          for record in data['__ENTITIES']:
              res.append((str(record['__KEY']),str(record['name']))) 
          print res
          self.tranche = res
          return
  
  @api.model
  def _get_tranche(self):
  
          values = {'$top' : 100,
                      '$filter' : "'name==:1&amp;&amp;parent!=null'",
                      '$params' : '\'["*"]\'' }
          response = requests.get('http://localhost:8081/rest/Project/name',
                                   auth=('admin', 'admin'),
                                   params=values)
          data = response.json()
          res = []
          for record in data['__ENTITIES']:
              res.append((record['__KEY'], record['name']))
          return res
  </code></pre>
  
  <p>But I get this error</p>
  
  <pre><code>File "/opt/odoo/odoo/openerp/fields.py", line 1529, in convert_to_cache
  raise ValueError("Wrong value for %s: %r" % (self, value))
  ValueError: Wrong value for crm.lead.tranche: [('6', 'Tranche I'), ('7', 'Tranche II'), ('8', 'Tranche III')]
  </code></pre>
  
  <p>Help me please...</p>