Hello everyone, I am seeking assistance with integrating odoo 18, odoo 19 Odoo's API with a React Native Expo application.Is it possible to establish this connection? If so, could someone please provide a detailed example of how to achieve this integration? Thank you in advance for your help!
此问题已终结
Yes, Odoo 18 and Odoo 19 can be integrated with a React Native Expo application using Odoo's JSON-RPC API.
A common approach is to authenticate the user and then call Odoo models using the /web/session/authenticate and /web/dataset/call_kw endpoints.
Example authentication request:
const response = await fetch(
"https://your-odoo-instance.com/web/session/authenticate",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
params: {
db: "your_database",
login: "user@example.com",
password: "your_password",
},
}),
}
);
const result = await response.json();
Reading records from Odoo:
const response = await fetch(
"https://your-odoo-instance.com/web/dataset/call_kw",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
credentials: "include",
body: JSON.stringify({
jsonrpc: "2.0",
method: "call",
params: {
model: "res.partner",
method: "search_read",
args: [[]],
kwargs: {
fields: ["name", "email"],
limit: 10,
},
},
}),
}
);
const partners = await response.json();
The same approach can be used for create, write, unlink, and custom model methods by changing the method name in call_kw.
For production deployments, avoid storing Odoo user credentials directly in the mobile application. A common practice is to create a custom controller in Odoo that exposes only the required endpoints and handles authentication securely.
Hope that helps!
| 相关帖文 | 回复 | 查看 | 活动 | |
|---|---|---|---|---|
|
|
0
4月 26
|
7 | ||
|
|
3
10月 25
|
3432 | ||
|
|
2
12月 24
|
5104 | ||
|
|
0
10月 23
|
4590 | ||
|
|
1
2月 22
|
6184 |
Hello,
Please review this:
https://www.odoo.com/documentation/18.0/developer/reference/external_api.html
So what do you want to know?
Thank you, but is not explain detail