This question has been flagged
1 Reply
5724 Views

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
Discard
Best Answer

You only need to use read:

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

Avatar
Discard