This question has been flagged

I need to read a field in an object, which is purchase.order, from another object product.product This field is a selection type field, so if this field has si selected then do _get_product_available_func('done')which is a function already declared in product.product

This is the selection field in purchase.order

'sel_cert' : fields.selection([('si', 'Si'),('no','No')], 'Origen Certificado'),

And this the function which should "retrieve" that field from product.product

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

The function which has _get_product_available_func('done)

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',))

So, i need to "execute" _get_product_available_func('done') in product.product when field sel_cert in purchase.order has the value si selected , but is giving me an error, here's the traceback in openerp server:

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'

Perhaps i should call _product_qty_available instead of _get_product_available_func?

Anybody could clarify this?

Thanks in advance!

Avatar
Discard