跳至内容
菜单
此问题已终结
1 回复
7010 查看

I'm starting to write some actual working Odoo code. That's great. But now I have this slow ORM stuff here:

            obj = pool[model]
            ids = obj.search(cr, uid, [], context=context)
            items = obj.browse(cr, uid, ids, context=context)
            custom_map = dict([(i.custom_field, i.id)
                                              for i in items
                                              if i.custom_field != ''])

I would like to fetch only the custom_field (mapped to the id), not the rest. But I have a feeling that now it's actually fetching all data (which unfortunately includes base64 images). Is there an easy way to only fetch the two fields I need? (i.e. id and custom_field)

形象
丢弃
最佳答案

You only need to use read:

obj.read(cr, uid, ids, fields=[field1, field2])

形象
丢弃
相关帖文 回复 查看 活动
1
3月 15
5193
1
4月 22
3561
1
7月 21
8485
9
2月 17
11143
0
10月 16
4005