我正在尝试从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
{1}}对象,这是selection
类型字段,因此,如果此字段已选中si
,请执行_get_product_available_func(('done'))
仅仅是为了冗长的事情:)
那么,任何人都可以对此有所了解吗?
提前致谢!
答案 0 :(得分:2)
好像你错过了该行uid
之后的逗号。