Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
2784 Weergaven

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
Annuleer
Beste antwoord

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
jan. 24
2571
0
okt. 22
3014
0
apr. 22
2952
0
mrt. 22
2153
2
mei 21
9291