Skip to Content
Menú
This question has been flagged
1 Respondre
2552 Vistes

Hi.

I've been trying to fetch multiple invoice lines by id using the read​  operation from the XML-Rpc API, with Odoo 16. My request looks like this:

I would LOVE to provide an example, unfortunately this question board
confuses XML with LINKS that I'm not allowed to post because I don't have
20 karma. That is, despite the fact that there are ZERO links in this XML document.
So I can't ask anything in this board, and I'll never be able to make Odoo work for my clients.
THANK YOU VERY MUCH ODOO. What's happening ? You can't provide the specs for your own API *AND* you can't provide a question board that works ? Way to boost trust levels !

But when sending this query, Odoo responds that the read​ function can only take up to 3 positional arguments.

If you look at my XML-RPC query, you can see that there is only one positional argument after read​: the only positional argument is an array of ids.

Why doesn't it work ? How am I supposed to do this ? Can the community fix the lack of proper documentation for the external API ?

Avatar
Descartar
Best Answer

Hi,

You can retrieve or read data from multiple records by passing the ID's of the record in list. See below example:

move_lines = models.execute_kw(db, uid, password, 'account.move.line', 'read', [[3,2]])


But as there is a bug currently which has to be fixed as of now, you will receive an error if you run the above code. In order to tackle the issue and fetch the data, you have to explicitly specify the name of fields from which you need to read the data as follows:


fields_to_read = ['partner_id']
move_lines = models.execute_kw(db, uid, password, 'account.move.line', 'read', [[3,2]], {'fields': fields_to_read}) 


Don't specify the fields like tax_totals which hold's the data as dictionary and it will return error.


Thanks

Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
de gen. 24
2251
0
d’oct. 22
2787
0
d’abr. 22
2785
0
de març 22
1945
2
de maig 21
9092