Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
6997 Visninger

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)

Avatar
Kassér
Bedste svar

You only need to use read:

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

Avatar
Kassér
Related Posts Besvarelser Visninger Aktivitet
1
mar. 15
5176
1
apr. 22
3548
1
jul. 21
8475
9
feb. 17
11116
0
okt. 16
4002