This question has been flagged
1 Reply
4107 Views

how to access all the field from the relational field like many2many and one2many from webapi,

when i use read method from call_kw its just return the ID, so i need to make new request to the object based on the ID from the first request,

any idea?

Avatar
Discard
Best Answer

If you just want to read fields use this code :

models.execute_kw(db, uid, password,
    'res.partner', 'search_read',
    [[['is_company', '=', True], ['customer', '=', True]]],
    {'fields': ['name', 'country_id', 'comment'], 'limit': 5})
Avatar
Discard
Author

yes, that code is right

but what about if we want to retrieve one2many field and want to get the name field?

lets say the country_id is one2many field it will return list of ids [1,2,3],

what i want to achieve is, that i can get other fields from that one2many field

i think you should search using the ids you got.

you can use this to know type of the field

models.execute_kw(

db, uid, password, 'model_name', 'fields_get',

[], {'attributes': ['string', 'help', 'type']})

Author

yes thats what i did for now,

i just search the odoo flow and its just use the same method that it will make another request based on the ids, thanks anyway for your help