1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
|
%global _empty_manifest_terminate_build 0
Name: python-aio-odoorpc-base
Version: 3.0.4
Release: 1
Summary: Fast, simple Odoo RPC package with sync and async functions to pilot Odoo's jsonrpc API. Check aio-odoorpc for a higher-level, friendlier interface.
License: CC0-1.0
URL: https://github.com/mbello/aio-odoorpc-base
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/43/ab/0b47d94fb35e08d96dc17b6b29cfff056361650d3cf8477eff885b16b425/aio-odoorpc-base-3.0.4.tar.gz
BuildArch: noarch
%description
## Base functions to pilot Odoo's jsonrpc API (aio-odoorpc-base)
### Description:
This python package implements a **complete** set of methods to access
Odoo's external API (using jsonrpc rather than xmlrpc).
It offers an almost-exact mirror of Odoo's external API, even parameter names are the same.
It is 'almost-exact' because 'execute' is skipped in favor of 'execute_kw' only and the
It is 'almost-exact' because 'execute' is skipped in favor of 'execute_kw' only and the
API methods from the 'db' service: 'list', 'drop', 'dump', 'rename', 'restore' are here
implemented with names 'list_databases', 'drop_database', 'dump_database', 'rename_database'
and 'restore_database' respectively.
The 'documentation' offered by this package is mostly in the form of proper type
annotations so that you have a better idea of what kind of data each API method expects.
Other than that, developers are recommended to go study Odoo's external API by reading the
source code at (https://github.com/odoo/odoo/tree/master/odoo/service). The three API services
'object', 'common' and 'db' are implemented there in files model.py, common.py and db.py
respectively. On each of these python files, a 'dispatch' method is implemented for the service
in question. The methods available on the external service api are usually those prefixed with
'exp_' in the method name, with the exception of the 'object' service which only exposes
'execute' and 'execute_kw'.
All functions offered by this package are available in both async and sync versions.
Odoo's API methods implemented:
- about
- authenticate
- change_admin_password
- create_database
- db_exist
- drop_database
- dump_database
- duplicate_database
- execute_kw
- list_countries
- list_databases
- list_lang
- login
- migrate_databases
- rename_database
- restore_database
- server_version
- version
All methods take as first 2 parameters:
- **http_client**: a callable or an instance of a compatible http_client (it must implement a 'post'
method that accepts a 'url' and a 'json' parameter. Packages 'requests', 'httpx' and 'aiohttp' are
compatible).
If http_client is a callable, it will be called with a dict as the post payload and must return a
response object with a '.json()' method that may be synchronous or asynchronous (when using the async
functions). It must return a dict or dict-like object representing the reponse.
- **url**: the complete URL of your Odoo's jsonrpc endpoint. Usually something like
'https://odoo.acme.com/jsonrpc' or 'https://odoo.acme.com:8443/jsonrpc'.
Remaining parameters on each method are those expected by Odoo's external API, with identical names
as you will find on Odoo's source code. The method 'jsonrpc' is the low-level method in this package that
actually does all the HTTP calls for all implemented methods.
By default, when you issue 'from aio_odoorpc_base import ...' you will be importing the async methods.
If you want the sync methods you must import from 'aio_odoorpc_base.sync'. You may also use
'aio_odoorpc_base.aio' if you prefer to be explicit on whether you are importing sync or async code.
### aio-odoorpc: a higher-level API
In practice, you may notice that 99% of the time you will be calling the 'execute_kw' method
which is what allows you to deal with Odoo's models, reading and writing actual business data
via the model methods 'search', 'read', 'search_read', 'search_count', 'write', 'create', etc.
While this package only offers you a bare 'execute_kw' method and a helper 'execute_kwargs',
the higher-level package 'aio-odoorpc' expands over this one adding higher-level objects and methods
(such as 'search', 'read', 'search_read', 'search_count', 'write', 'create', etc) to consume those
model methods through calls to 'execute_kw' external API method.
### No dependencies:
No dependency is not a promise, just a preference. It may change in the future, but only if for very
good reason. Here, are free to use whatever HTTP Client library you want.
I am willing to make modifications in the code in order to support other http client solutions,
just get in touch (use the project's github repository for that).
While it would be easier if this package shipped with a specific http client dependency, it should be
noted that having the possibility to reuse HTTP sessions is a great opportunity to improve the
speed of your running code. Also, it is possible that your project is already using some http client
library and here you have the opportunity to use it.
Remember that you must use an async http client library if you are going to use the async functions,
or use a synchronous http client library if you are going to use the sync function.
### Python HTTP Client packages known to be compatible:
- sync-only: 'requests'
- async-only: 'aiohttp'
- sync and async: 'httpx'
### Motivation:
The package 'odoorpc' is the most used and better maintained package to let you easily consume Odoo's
external API. It has lots of functionality, good documentation, a large user base and was developed
by people that are very experienced with Odoo in general and big contributors to the Odoo Community.
In other words, if you are taking your first steps and do not need an async interface now, start with
odoorpc.
However, for my needs, once I was developing Odoo integrations that needed to make hundreds of calls
to the Odoo API to complete a single job, I began to sorely miss an async interface as well as more
control over the HTTP client used (I wished for HTTP2 support and connection polling/reuse).
Also, as I understood Odoo's external API, it started to sound like 'odoorpc' was too big for a task
too simple. For instance, most of the time (like 99,99% of the time), you will be calling to a single
jsonrpc method called 'execute_kw'. It is the same call over and over just changing the payload which
itself is a simple json.
So I decided to develop a new package myself, made it async-first and tryed to keep it as simple as
possible. Also, I decided to split it in two, a very simple base package (this one) with only methods
that mirror those in Odoo's external API and another one 'aio-odoorpc' that adds another layer to
implement Odoo's model methods like 'search', 'search_read', 'read', etc. as well as an object model
to instantiate a class once and then make simple method invocation with few parameters to access
what you need.
### Useful tips about Odoo's external API:
- The 'login' call is really only a lookup of the user_id (an int) of a user given a
database name, user/login name and password. If you are using this RPC client over and over in your
code, maybe even calling from a stateless cloud service, you should consider finding out the
user id (uid) of the user and pass the uid instead of the username to the constructor of AsyncOdooRPC.
This way, you do not need to call the login() RPC method to retrieve the uid, saving a RPC call;
- The uid mentioned above is not a session-like id. It is really only the database id of the user
and it never expires. There is really no 'login' or 'session initiation' step required to access
Odoo's external API if you know the uid from the beginning;
### Other things to know about this module:
- It ships will a good suite of tests that run against an OCA runbot instance;
- Asyncio is a python3 thing, so no python2 support;
- Type hints are used everywhere;
- This package uses jsonrpc only (no xmlrpc). There is a lack of async xmlrpc tooling and
jsonrpc is considered the best RPC protocol in Odoo (faster, more widely used);
- The synchronous version of the code is generated automatically from the asynchronous code, so at
least for now the effort to maintain both is minimal.
- I am willing to take patches and to add other contributors to this project. Feel free to get in touch,
the github page is the best place to interact with the project and the project's author;
- I only develop and run code in Linux environments, if you find a bug under other OS I am happy
to take patches but I will not myself spend time looking into these eventual bugs;
### Usage
Ok, so let's start with some examples. I will omit the event_loop logic, I assume that if you want
to use an async module you already have that sorted out yourself or through a framework like FastAPI.
All examples below could also be called using the synchronous OdooRPC object, but without the
'await' syntax.
I recommend that you check the tests folder for many more examples. Also, the codebase is very very short,
do refer to it as well.
```
from aio_odoorpc_base.aio import login, execute_kw
from aio_odoorpc_base.helpers import execute_kwargs
import httpx
url = 'https://odoo.acme.com/jsonrpc'
async with httpx.AsyncClient() as client:
uid = await login(http_client=client, url=url, db='acme', login='demo', password='demo')
kwargs = execute_kwargs(fields=['partner_id', 'date_order', 'amount_total'],
limit=1000, offset=0, order='amount_total DESC')
data = await execute_kw(http_client=client,
url=url,
db='acme',
uid=uid,
password='demo',
obj='sale.order',
method='search_read',
args=[],
kw=kwargs)
```
%package -n python3-aio-odoorpc-base
Summary: Fast, simple Odoo RPC package with sync and async functions to pilot Odoo's jsonrpc API. Check aio-odoorpc for a higher-level, friendlier interface.
Provides: python-aio-odoorpc-base
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-aio-odoorpc-base
## Base functions to pilot Odoo's jsonrpc API (aio-odoorpc-base)
### Description:
This python package implements a **complete** set of methods to access
Odoo's external API (using jsonrpc rather than xmlrpc).
It offers an almost-exact mirror of Odoo's external API, even parameter names are the same.
It is 'almost-exact' because 'execute' is skipped in favor of 'execute_kw' only and the
It is 'almost-exact' because 'execute' is skipped in favor of 'execute_kw' only and the
API methods from the 'db' service: 'list', 'drop', 'dump', 'rename', 'restore' are here
implemented with names 'list_databases', 'drop_database', 'dump_database', 'rename_database'
and 'restore_database' respectively.
The 'documentation' offered by this package is mostly in the form of proper type
annotations so that you have a better idea of what kind of data each API method expects.
Other than that, developers are recommended to go study Odoo's external API by reading the
source code at (https://github.com/odoo/odoo/tree/master/odoo/service). The three API services
'object', 'common' and 'db' are implemented there in files model.py, common.py and db.py
respectively. On each of these python files, a 'dispatch' method is implemented for the service
in question. The methods available on the external service api are usually those prefixed with
'exp_' in the method name, with the exception of the 'object' service which only exposes
'execute' and 'execute_kw'.
All functions offered by this package are available in both async and sync versions.
Odoo's API methods implemented:
- about
- authenticate
- change_admin_password
- create_database
- db_exist
- drop_database
- dump_database
- duplicate_database
- execute_kw
- list_countries
- list_databases
- list_lang
- login
- migrate_databases
- rename_database
- restore_database
- server_version
- version
All methods take as first 2 parameters:
- **http_client**: a callable or an instance of a compatible http_client (it must implement a 'post'
method that accepts a 'url' and a 'json' parameter. Packages 'requests', 'httpx' and 'aiohttp' are
compatible).
If http_client is a callable, it will be called with a dict as the post payload and must return a
response object with a '.json()' method that may be synchronous or asynchronous (when using the async
functions). It must return a dict or dict-like object representing the reponse.
- **url**: the complete URL of your Odoo's jsonrpc endpoint. Usually something like
'https://odoo.acme.com/jsonrpc' or 'https://odoo.acme.com:8443/jsonrpc'.
Remaining parameters on each method are those expected by Odoo's external API, with identical names
as you will find on Odoo's source code. The method 'jsonrpc' is the low-level method in this package that
actually does all the HTTP calls for all implemented methods.
By default, when you issue 'from aio_odoorpc_base import ...' you will be importing the async methods.
If you want the sync methods you must import from 'aio_odoorpc_base.sync'. You may also use
'aio_odoorpc_base.aio' if you prefer to be explicit on whether you are importing sync or async code.
### aio-odoorpc: a higher-level API
In practice, you may notice that 99% of the time you will be calling the 'execute_kw' method
which is what allows you to deal with Odoo's models, reading and writing actual business data
via the model methods 'search', 'read', 'search_read', 'search_count', 'write', 'create', etc.
While this package only offers you a bare 'execute_kw' method and a helper 'execute_kwargs',
the higher-level package 'aio-odoorpc' expands over this one adding higher-level objects and methods
(such as 'search', 'read', 'search_read', 'search_count', 'write', 'create', etc) to consume those
model methods through calls to 'execute_kw' external API method.
### No dependencies:
No dependency is not a promise, just a preference. It may change in the future, but only if for very
good reason. Here, are free to use whatever HTTP Client library you want.
I am willing to make modifications in the code in order to support other http client solutions,
just get in touch (use the project's github repository for that).
While it would be easier if this package shipped with a specific http client dependency, it should be
noted that having the possibility to reuse HTTP sessions is a great opportunity to improve the
speed of your running code. Also, it is possible that your project is already using some http client
library and here you have the opportunity to use it.
Remember that you must use an async http client library if you are going to use the async functions,
or use a synchronous http client library if you are going to use the sync function.
### Python HTTP Client packages known to be compatible:
- sync-only: 'requests'
- async-only: 'aiohttp'
- sync and async: 'httpx'
### Motivation:
The package 'odoorpc' is the most used and better maintained package to let you easily consume Odoo's
external API. It has lots of functionality, good documentation, a large user base and was developed
by people that are very experienced with Odoo in general and big contributors to the Odoo Community.
In other words, if you are taking your first steps and do not need an async interface now, start with
odoorpc.
However, for my needs, once I was developing Odoo integrations that needed to make hundreds of calls
to the Odoo API to complete a single job, I began to sorely miss an async interface as well as more
control over the HTTP client used (I wished for HTTP2 support and connection polling/reuse).
Also, as I understood Odoo's external API, it started to sound like 'odoorpc' was too big for a task
too simple. For instance, most of the time (like 99,99% of the time), you will be calling to a single
jsonrpc method called 'execute_kw'. It is the same call over and over just changing the payload which
itself is a simple json.
So I decided to develop a new package myself, made it async-first and tryed to keep it as simple as
possible. Also, I decided to split it in two, a very simple base package (this one) with only methods
that mirror those in Odoo's external API and another one 'aio-odoorpc' that adds another layer to
implement Odoo's model methods like 'search', 'search_read', 'read', etc. as well as an object model
to instantiate a class once and then make simple method invocation with few parameters to access
what you need.
### Useful tips about Odoo's external API:
- The 'login' call is really only a lookup of the user_id (an int) of a user given a
database name, user/login name and password. If you are using this RPC client over and over in your
code, maybe even calling from a stateless cloud service, you should consider finding out the
user id (uid) of the user and pass the uid instead of the username to the constructor of AsyncOdooRPC.
This way, you do not need to call the login() RPC method to retrieve the uid, saving a RPC call;
- The uid mentioned above is not a session-like id. It is really only the database id of the user
and it never expires. There is really no 'login' or 'session initiation' step required to access
Odoo's external API if you know the uid from the beginning;
### Other things to know about this module:
- It ships will a good suite of tests that run against an OCA runbot instance;
- Asyncio is a python3 thing, so no python2 support;
- Type hints are used everywhere;
- This package uses jsonrpc only (no xmlrpc). There is a lack of async xmlrpc tooling and
jsonrpc is considered the best RPC protocol in Odoo (faster, more widely used);
- The synchronous version of the code is generated automatically from the asynchronous code, so at
least for now the effort to maintain both is minimal.
- I am willing to take patches and to add other contributors to this project. Feel free to get in touch,
the github page is the best place to interact with the project and the project's author;
- I only develop and run code in Linux environments, if you find a bug under other OS I am happy
to take patches but I will not myself spend time looking into these eventual bugs;
### Usage
Ok, so let's start with some examples. I will omit the event_loop logic, I assume that if you want
to use an async module you already have that sorted out yourself or through a framework like FastAPI.
All examples below could also be called using the synchronous OdooRPC object, but without the
'await' syntax.
I recommend that you check the tests folder for many more examples. Also, the codebase is very very short,
do refer to it as well.
```
from aio_odoorpc_base.aio import login, execute_kw
from aio_odoorpc_base.helpers import execute_kwargs
import httpx
url = 'https://odoo.acme.com/jsonrpc'
async with httpx.AsyncClient() as client:
uid = await login(http_client=client, url=url, db='acme', login='demo', password='demo')
kwargs = execute_kwargs(fields=['partner_id', 'date_order', 'amount_total'],
limit=1000, offset=0, order='amount_total DESC')
data = await execute_kw(http_client=client,
url=url,
db='acme',
uid=uid,
password='demo',
obj='sale.order',
method='search_read',
args=[],
kw=kwargs)
```
%package help
Summary: Development documents and examples for aio-odoorpc-base
Provides: python3-aio-odoorpc-base-doc
%description help
## Base functions to pilot Odoo's jsonrpc API (aio-odoorpc-base)
### Description:
This python package implements a **complete** set of methods to access
Odoo's external API (using jsonrpc rather than xmlrpc).
It offers an almost-exact mirror of Odoo's external API, even parameter names are the same.
It is 'almost-exact' because 'execute' is skipped in favor of 'execute_kw' only and the
It is 'almost-exact' because 'execute' is skipped in favor of 'execute_kw' only and the
API methods from the 'db' service: 'list', 'drop', 'dump', 'rename', 'restore' are here
implemented with names 'list_databases', 'drop_database', 'dump_database', 'rename_database'
and 'restore_database' respectively.
The 'documentation' offered by this package is mostly in the form of proper type
annotations so that you have a better idea of what kind of data each API method expects.
Other than that, developers are recommended to go study Odoo's external API by reading the
source code at (https://github.com/odoo/odoo/tree/master/odoo/service). The three API services
'object', 'common' and 'db' are implemented there in files model.py, common.py and db.py
respectively. On each of these python files, a 'dispatch' method is implemented for the service
in question. The methods available on the external service api are usually those prefixed with
'exp_' in the method name, with the exception of the 'object' service which only exposes
'execute' and 'execute_kw'.
All functions offered by this package are available in both async and sync versions.
Odoo's API methods implemented:
- about
- authenticate
- change_admin_password
- create_database
- db_exist
- drop_database
- dump_database
- duplicate_database
- execute_kw
- list_countries
- list_databases
- list_lang
- login
- migrate_databases
- rename_database
- restore_database
- server_version
- version
All methods take as first 2 parameters:
- **http_client**: a callable or an instance of a compatible http_client (it must implement a 'post'
method that accepts a 'url' and a 'json' parameter. Packages 'requests', 'httpx' and 'aiohttp' are
compatible).
If http_client is a callable, it will be called with a dict as the post payload and must return a
response object with a '.json()' method that may be synchronous or asynchronous (when using the async
functions). It must return a dict or dict-like object representing the reponse.
- **url**: the complete URL of your Odoo's jsonrpc endpoint. Usually something like
'https://odoo.acme.com/jsonrpc' or 'https://odoo.acme.com:8443/jsonrpc'.
Remaining parameters on each method are those expected by Odoo's external API, with identical names
as you will find on Odoo's source code. The method 'jsonrpc' is the low-level method in this package that
actually does all the HTTP calls for all implemented methods.
By default, when you issue 'from aio_odoorpc_base import ...' you will be importing the async methods.
If you want the sync methods you must import from 'aio_odoorpc_base.sync'. You may also use
'aio_odoorpc_base.aio' if you prefer to be explicit on whether you are importing sync or async code.
### aio-odoorpc: a higher-level API
In practice, you may notice that 99% of the time you will be calling the 'execute_kw' method
which is what allows you to deal with Odoo's models, reading and writing actual business data
via the model methods 'search', 'read', 'search_read', 'search_count', 'write', 'create', etc.
While this package only offers you a bare 'execute_kw' method and a helper 'execute_kwargs',
the higher-level package 'aio-odoorpc' expands over this one adding higher-level objects and methods
(such as 'search', 'read', 'search_read', 'search_count', 'write', 'create', etc) to consume those
model methods through calls to 'execute_kw' external API method.
### No dependencies:
No dependency is not a promise, just a preference. It may change in the future, but only if for very
good reason. Here, are free to use whatever HTTP Client library you want.
I am willing to make modifications in the code in order to support other http client solutions,
just get in touch (use the project's github repository for that).
While it would be easier if this package shipped with a specific http client dependency, it should be
noted that having the possibility to reuse HTTP sessions is a great opportunity to improve the
speed of your running code. Also, it is possible that your project is already using some http client
library and here you have the opportunity to use it.
Remember that you must use an async http client library if you are going to use the async functions,
or use a synchronous http client library if you are going to use the sync function.
### Python HTTP Client packages known to be compatible:
- sync-only: 'requests'
- async-only: 'aiohttp'
- sync and async: 'httpx'
### Motivation:
The package 'odoorpc' is the most used and better maintained package to let you easily consume Odoo's
external API. It has lots of functionality, good documentation, a large user base and was developed
by people that are very experienced with Odoo in general and big contributors to the Odoo Community.
In other words, if you are taking your first steps and do not need an async interface now, start with
odoorpc.
However, for my needs, once I was developing Odoo integrations that needed to make hundreds of calls
to the Odoo API to complete a single job, I began to sorely miss an async interface as well as more
control over the HTTP client used (I wished for HTTP2 support and connection polling/reuse).
Also, as I understood Odoo's external API, it started to sound like 'odoorpc' was too big for a task
too simple. For instance, most of the time (like 99,99% of the time), you will be calling to a single
jsonrpc method called 'execute_kw'. It is the same call over and over just changing the payload which
itself is a simple json.
So I decided to develop a new package myself, made it async-first and tryed to keep it as simple as
possible. Also, I decided to split it in two, a very simple base package (this one) with only methods
that mirror those in Odoo's external API and another one 'aio-odoorpc' that adds another layer to
implement Odoo's model methods like 'search', 'search_read', 'read', etc. as well as an object model
to instantiate a class once and then make simple method invocation with few parameters to access
what you need.
### Useful tips about Odoo's external API:
- The 'login' call is really only a lookup of the user_id (an int) of a user given a
database name, user/login name and password. If you are using this RPC client over and over in your
code, maybe even calling from a stateless cloud service, you should consider finding out the
user id (uid) of the user and pass the uid instead of the username to the constructor of AsyncOdooRPC.
This way, you do not need to call the login() RPC method to retrieve the uid, saving a RPC call;
- The uid mentioned above is not a session-like id. It is really only the database id of the user
and it never expires. There is really no 'login' or 'session initiation' step required to access
Odoo's external API if you know the uid from the beginning;
### Other things to know about this module:
- It ships will a good suite of tests that run against an OCA runbot instance;
- Asyncio is a python3 thing, so no python2 support;
- Type hints are used everywhere;
- This package uses jsonrpc only (no xmlrpc). There is a lack of async xmlrpc tooling and
jsonrpc is considered the best RPC protocol in Odoo (faster, more widely used);
- The synchronous version of the code is generated automatically from the asynchronous code, so at
least for now the effort to maintain both is minimal.
- I am willing to take patches and to add other contributors to this project. Feel free to get in touch,
the github page is the best place to interact with the project and the project's author;
- I only develop and run code in Linux environments, if you find a bug under other OS I am happy
to take patches but I will not myself spend time looking into these eventual bugs;
### Usage
Ok, so let's start with some examples. I will omit the event_loop logic, I assume that if you want
to use an async module you already have that sorted out yourself or through a framework like FastAPI.
All examples below could also be called using the synchronous OdooRPC object, but without the
'await' syntax.
I recommend that you check the tests folder for many more examples. Also, the codebase is very very short,
do refer to it as well.
```
from aio_odoorpc_base.aio import login, execute_kw
from aio_odoorpc_base.helpers import execute_kwargs
import httpx
url = 'https://odoo.acme.com/jsonrpc'
async with httpx.AsyncClient() as client:
uid = await login(http_client=client, url=url, db='acme', login='demo', password='demo')
kwargs = execute_kwargs(fields=['partner_id', 'date_order', 'amount_total'],
limit=1000, offset=0, order='amount_total DESC')
data = await execute_kw(http_client=client,
url=url,
db='acme',
uid=uid,
password='demo',
obj='sale.order',
method='search_read',
args=[],
kw=kwargs)
```
%prep
%autosetup -n aio-odoorpc-base-3.0.4
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-aio-odoorpc-base -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Wed May 31 2023 Python_Bot <Python_Bot@openeuler.org> - 3.0.4-1
- Package Spec generated
|