title: Decompose a OpenERP lambda
body: <p>In my OpenERP application, I have a lambda that I am trying to understand (currency_id):</p>
  
  <pre><code>_defaults = {
         'display_type': True,
         'journal_ids': [],
         'target_move': False,
         'currency_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.currency_id.id,
     }
  </code></pre>
  
  <p>So far, I understand it is doing this:</p>
  
  <ul>
  <li>start with table <strong>res_users</strong>, which has a <strong>company_id</strong> field</li>
  <li>uses the <strong>browse</strong> command to access a connected record</li>
  </ul>
  
  <p>The <strong>browse</strong> function has the prototype of: <strong>browse</strong>(cr, uid, ids, context=None). We are passing it the <strong>uid</strong> as the <strong>ids</strong>. <strong>Why are we passing the uid instead of ids?</strong></p>
  
  <p>The <strong>res_company</strong> table has the <strong>currency_id</strong> field.</p>
  
  <p>Then I assume it is using the foreign keys to access it via OpenERP's ORM. <strong>How does the ORM know how to connect to the **res_company</strong> field?**</p>
  
  <p>Similar question
  <a href="https://stackoverflow.com/questions/19293630/what-is-the-reason-of-using-defaults-and-lambda-in-python-for-openerp-developme/19294524#19294524">what is the reason of using _defaults and lambda in python for openerp development?</a></p>