Reputation: 96
What is main difference between following :
self.pool['res.partner'].browse(cr, uid, partner_id, context=context)
and
self.pool.get('res.partner').browse(cr, uid, partner_id, context)
As per my understanding both returns single record of type res.partner if partner_id e.g. 1
Then why it is used like this.
Upvotes: 0
Views: 190
Reputation: 12573
if self.pool
is a dictionary (I hope :) ) then self.pool['res.partner']
will raise an exception (KeyError
) if the 'res.partner' is not present in that dictionary.
self.pool.get('res.partner')
in the same case will return default value (which is None).
If you want to specify a different default value, you can do it like that: self.pool.get('res.partner',some_def_value)
.
Upvotes: 3