项目作者: dennybiasiolli

项目描述 :
Odoo xmlrpc client
高级语言: TypeScript
项目地址: git://github.com/dennybiasiolli/odoo-xmlrpc-client.git
创建时间: 2020-06-16T14:07:19Z
项目社区:https://github.com/dennybiasiolli/odoo-xmlrpc-client

开源协议:

下载


Odoo xmlrpc client

See CONTRIBUTING.md to contribute to this project.

Installation

  1. $ npm install odoo-xmlrpc-client

Example

Disclaimer: please, refer to
Odoo External API documentation
for detailed usage of odoo.executeKw parameters.

Connection configuration

  1. const { Odoo } = require('odoo-xmlrpc-client');
  2. const odoo = Odoo({
  3. url: 'http://localhost', // odoo server url
  4. // port: 8069, // <optional odoo port>
  5. db: 'odoo', // database name
  6. username: '', // odoo username
  7. password: '', // odoo password
  8. });

Usage with promises

  1. odoo.authenticate().then(() => {
  2. odoo.executeKw(
  3. 'res.partner',
  4. 'search',
  5. [[['customer', '=', true]]],
  6. {}
  7. ).then(ids => {
  8. console.log('ids: ', ids);
  9. odoo.executeKw(
  10. 'res.partner',
  11. 'read',
  12. ids,
  13. { 'fields': ['name', 'country_id', 'comment', 'is_company', 'customer'] }
  14. ).then(res => {
  15. console.log('Results: ', res);
  16. })
  17. });
  18. })

Usage with async/await

  1. await odoo.authenticate();
  2. console.log('Connected to Odoo server.');
  3. const ids = await odoo.executeKw(
  4. 'res.partner',
  5. 'search',
  6. [[['customer', '=', true]]],
  7. {}
  8. );
  9. console.log('ids: ', ids);
  10. const res = await odoo.executeKw(
  11. 'res.partner',
  12. 'read',
  13. ids,
  14. { 'fields': ['name', 'country_id', 'comment', 'is_company', 'customer'] }
  15. );
  16. console.log('Results: ', res);