我正在尝试从在 openerp 中具有此功能的另一个类中读取对象内的字段:
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
作为sel_cert
我试图从中读取的类中的字段self.pool.get
,我仍在学习 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 1133, in get
File "C:\Program Files\OpenERP 7.0-20130726-231403\Server\server\openerp\addons\product\product.py", line 456, in desc_cert
TypeError: 'int' object is unsubscriptable
我不明白代码有什么问题,我已经在account
模块中看到了一个非常相似的例子,我想要实现的是sel_cert
从purchase.order
对象中读取字段,这是一个selection
类型字段,所以如果这个字段si
选择了然后做_get_product_available_func(('done'))
只是为了冗长:)
那么,任何人都可以对此有所了解吗?
提前致谢!