Skip to Content
Menu
This question has been flagged
1 Reply
2549 Views

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
Discard
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
Discard
Related Posts Replies Views Activity
1
Jan 24
2249
0
Oct 22
2785
0
Apr 22
2784
0
Mar 22
1939
2
May 21
9089