title: How to return an existing ir.actions.act_window from Python in Odoo 10?
body: <p><strong>What I need</strong></p>
  
  <p>If the user clicks on my button, take him to different views of different models depending on a field of the current record.</p>
  
  <p><strong>What I did</strong></p>
  
  <p>I have declared a type <em>object</em> button to call a Python method. Inside it, I check the field. If its value is <em>A</em>, I redirect him to the model <em>X</em> and if its value is B, I redirect him to the model <em>Y</em>.</p>
  
  <p><strong>The code</strong></p>
  
  <pre><code>@api.multi
  def my_button_method(self):
      self.ensure_one()
      if self.my_field == 'A':
          action_id = self.env.ref(
              'my_module.my_ir_actions_act_window_A')
          return action_id.__dict__
      elif self.my_field == 'B':
          action_id = self.env.ref(
              'my_module.my_ir_actions_act_window_B')
      else:
          action_id = False
      if action_id:
          return action_id.__dict__
  </code></pre>
  
  <p>If I write this after the definition of <code>action_id</code>:</p>
  
  <pre><code>_logger.info(action_id.name)
  _logger.info(action_id.type)
  _logger.info(action_id.res_model)
  _logger.info(action_id.view_type)
  _logger.info(action_id.view_mode)
  _logger.info(action_id.search_view_id)
  _logger.info(action_id.help)
  </code></pre>
  
  <p>I get the right values. So, after googling I saw that <code>__dict__</code> gives you  a dictionary whose keys are the attributes of the object and whose values the values of those attributes.</p>
  
  <p>But the code is giving an error because <code>action_id.__dict__</code> doesn't return a dictionary with the expected attributes of the action and its values, but the following instead:</p>
  
  <pre><code>{
      '_prefetch': defaultdict(
          &lt;type 'set'&gt;,
          {
              'ir.actions.act_window': set([449])
          }
      ),
      'env': &lt;odoo.api.Environment object at 0x7f0aa7ed7cd0&gt;,
      '_ids': (449,)
  }
  </code></pre>
  
  <p>Can anyone tell me why? I'm trying to avoid this code:</p>
  
  <pre><code>@api.multi
  def my_button_method(self):
      self.ensure_one()
      if self.my_field == 'A':
          action_id = self.env.ref(
              'my_module.my_ir_actions_act_window_A')
      elif self.my_field == 'B':
          action_id = self.env.ref(
              'my_module.my_ir_actions_act_window_B')
      else:
          action_id
      if action_id:
          return {
              'name': action_id.name,
              'type': action_id.type,
              'res_model': action_id.res_model,
              'view_type': action_id.view_type,
              'view_mode': action_id.view_mode,
              'search_view_id': action_id.search_view_id,
              'help': action_id.help,
          }
  </code></pre>
  
  <p>May be there is a much better solution using a server action, if so, does anyone know how?</p>