active_ids で連結された ID のリストを返す単純な関数を作成しようとしています。しかし、私はこのエラーを受け取り続けます:
TypeError: 'builtin_function_or_method' object has no attribute '__getitem__'
コードは次のとおりです。
def _test(self, cr, uid, context=None):
if context is None:
return False
result = 'Sel: '
for id in context.get['active_ids']:
result = result + '[' + id + ']'
return result
_columns = {
'test': fields.text('Test')
}
_defaults = {
'test': _test
}
私が理解できないのは、関数の戻り値の型だと思います。既存のコードを見ると、配列 ([]) が返されたり、{} が返されたり、res[0][0] が単一の値であると想定される場合があります。
手伝ってください。
ありがとう
編集:作業コード:
def _test(self, cr, uid, context=None):
if context is None:
return False
result = 'Sel: '
if context.get('active_ids'):
for id in context.get('active_ids'):
result = result + '[' + str(id) + ']'
return result