我需要读取一个对象中的一个字段,也就是purchase.order
从另一个对象中读取product.product
这个字段是一个选择类型字段,所以如果这个字段已经si
被选中,那么 do _get_product_available_func(('done'))
which 是一个已经声明的函数product.product
这是中的选择字段purchase.order
'sel_cert' : fields.selection([('si', 'Si'),('no','No')], 'Origen Certificado'),
这应该是“检索”该字段的功能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
具有的功能_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',))
所以,我需要_get_product_available_func(('done'))
在product.product
字段sel_cert
中purchase.order
的值有值时“执行” si
,但给我一个错误,这是 openerp 服务器中的回溯:
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'
也许我应该打电话_product_qty_available
来代替_get_product_available_func
?
任何人都可以澄清这一点?
提前致谢!