In my OpenERP application, I have a lambda that I am trying to understand (currency_id):
_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,
}
So far, I understand it is doing this:
- start with table res_users, which has a company_id field
- uses the browse command to access a connected record
The browse function has the prototype of: browse(cr, uid, ids, context=None). We are passing it the uid as the ids. Why are we passing the uid instead of ids?
The res_company table has the currency_id field.
Then I assume it is using the foreign keys to access it via OpenERP's ORM. How does the ORM know how to connect to the **res_company field?**
Similar question what is the reason of using _defaults and lambda in python for openerp development?