title: AttributeError: 'NoneType' object has no attribute 'get' - Python - OpenErp
body: <p>I need to read a field in an object, which is <code>purchase.order</code> , from another object <code>product.product</code> 
  This field is a selection type field, so if this field has <code>si</code> is selected then do <code>_get_product_available_func(('done'))</code> which is a function already declared in <code>product.product</code></p>
  
  <p>This is the selection field in <code>purchase.order</code></p>
  
  <pre><code>'sel_cert' : fields.selection([('si', 'Si'),('no','No')], 'Origen Certificado'),
  </code></pre>
  
  <p>And this the function which should "retrieve" that field from <code>product.product</code></p>
  
  <pre><code>def desc_cert(self, cr, uid, ids, field_name, field_args, context=None):
      obj = self.pool.get('purchase.order')
      pids = obj.search(cr, uid, [('sel_cert', '=', 'si')])
      val = self._get_product_available_func(('done'))
      if pids == 'si':
              return val
  </code></pre>
  
  <p>The function which has <code>_get_product_available_func(('done))</code></p>
  
  <pre><code>def _get_product_available_func(states, what):
      def _product_available(self, cr, uid, ids, name, arg, context=None):
          return {}.fromkeys(ids, 0.0)
      return _product_available
  
  _product_qty_available = _get_product_available_func(('done',), ('in', 'out'))
  _product_certificado_qty = _get_product_available_func(('done',), ('in', 'out'))
  _product_virtual_available = _get_product_available_func(('confirmed','waiting','assigned','done'), ('in', 'out'))
  _product_outgoing_qty = _get_product_available_func(('confirmed','waiting','assigned'), ('out',))
  _product_incoming_qty = _get_product_available_func(('confirmed','waiting','assigned'), ('in',))
  </code></pre>
  
  <p>So, i need to "execute" <code>_get_product_available_func(('done'))</code> in <code>product.product</code> when field <code>sel_cert</code> in <code>purchase.order</code> has the value <code>si</code> , but is giving me an error, here's the traceback in openerp server:</p>
  
  <pre><code>Server Traceback (most recent call last):
  File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\openerp\addons\web\session.py", line 89, in send
  File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\netsvc.py", line 292, in dispatch_rpc
  File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\service\web_services.py", line 626, in dispatch
  File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\osv\osv.py", line 188, in execute_kw
  File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\osv\osv.py", line 131, in wrapper
  File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\osv\osv.py", line 197, in execute
  File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\osv\osv.py", line 185, in execute_cr
  File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\osv\orm.py", line 3604, in read
  File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\osv\orm.py", line 3724, in _read_flat
  File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\.\openerp\osv\fields.py", line 1139, in get
  AttributeError: 'NoneType' object has no attribute 'get'
  </code></pre>
  
  <p>Perhaps i should call <code>_product_qty_available</code> instead in <code>_get_product_available_func</code>?</p>
  
  <p>Anybody could clarify this?</p>
  
  <p>Thanks in advance!</p>