تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
7038 أدوات العرض

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
مارس 15
5245
1
أبريل 22
3616
1
يوليو 21
8516
9
فبراير 17
11188
0
أكتوبر 16
4024