This project provides a TypeScript client for interacting with Odoo's XML-RPC API. It allows you to authenticate and execute various methods on Odoo models.
To install the package, use your favorite package manager. For example, with npm:
npm i odoo-xmlrpc-client
Here are some examples of how to use the Odoo XML-RPC client:
import { OdooXMLRPC, OdooConfig } from 'odoo-xmlrpc-client';
const config: OdooConfig = {
url: 'https://your-odoo-instance.com',
db: 'your-database',
username: 'your-username',
password: 'your-password',
};
const odoo = new OdooXMLRPC(config);
async function main() {
try {
const uid = await odoo.authenticate();
console.log('Authenticated with UID:', uid);
const result = await odoo.execute_kw('res.partner', 'create', [{
'company_type': "person",
'name': '',
'street': '',
'street2': '',
'zip': '',
'city': '',
'country_id': 19,
'email': '',
'mobile': '',
'is_company': false,
'lang': "en_US",
}])
console.log('Result:', result);
} catch (error) {
console.error('Error:', error);
}
}
main();
import { OdooXMLRPC, OdooConfig } from 'odoo-xmlrpc-client';
const config: OdooConfig = {
url: 'https://your-odoo-instance.com',
db: 'your-database',
username: 'your-username',
password: 'your-password',
};
const odoo = new OdooXMLRPC(config);
async function main() {
try {
const uid = await odoo.authenticate();
console.log('Authenticated with UID:', uid);
const result = await odoo.execute_kw(
'res.partner',
'search_read',
[[['is_company', '=', true]]],
{ fields: ['name', 'country_id', 'comment'], limit: 5 },
);
console.log('Result:', result);
} catch (error) {
console.error('Error:', error);
}
}
main();
This project is licensed under the MIT License - see the LICENSE file for details.