I need to read the field in the object that purchase.order from another product.product object This field is a selection type field, so if this field has si , then execute _get_product_available_func(('done')) , which is 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 is the function that should βextractβ this 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
Function that 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 the sel_cert field in purchase.order is si , but it gives me an error, here is the trace on the 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 ?
Can anyone clarify this?
Thanks in advance!