1.0.18 • Published 3 years ago

@truthtaicom/odoo-api-v2 v1.0.18

Weekly downloads
34
License
MIT
Repository
github
Last release
3 years ago

odoo-api

Odoo JSON-RPC client

This is a fork of odoo-connect with:

  • New added methods (read/count/readGroup)
  • HTTPS support
  • Native Args query: "id > 1", "name = Louis"
  • Aync/Await supported
  • Middleware
  • TypeScript

Install

npm install --save @truthtaicom/odoo-api-v2

OR

yarn add @truthtaicom/odoo-api-v2

Usage

import Odoo from '@truthtaicom/odoo-api-v2';

export default async function odooApi() {
  try {
    const odoo = new Odoo({
      host: 'localhost',
      port: 3979,
    });

    const client = await odoo.connect({
      database: 'odoo_db',
      username: 'your-user-name',
      password: '1234567890',
    });

    const data = await client.searchRead('res.partner', ['name = My Company'], { select: ['id', 'name'] });

    console.log('data', data);
  } catch (error) {
    console.log('ERROR', error);
  }
}

API

new Odoo(options)

Returns a Odoo instance | options | type | default | required | description | |---------|--------|------------|----------|-------------------| | host | string | localhost | yes | Odoo Host Address | | port | number | 80 | yes | Odoo Port |

odoo.connect(options)

Returns a Promise for a client object. | options | type | default | required | description | |----------|--------|---------|----------|-----------------------| | database | string | null | yes | Name of the database | | username | string | null | yes | Name of Odoo Username | | password | string | null | yes | Name of Odoo Password |

Client

client.readGroup(model, args, groupBy, params)

optionstypedefaultrequireddescription
modelstringnullyesModel to perform the action on.
argsarraynullnoList of parameters. Example: "id > 1", "name = Louis"
groupByarraynullnoFields to group by.
params.offsetnumber0noResult offset.
params.limitnumber5noMaximum number of results.
params.orderstringidnoName of the fields used to sort the results.
params.selectstring[][]noFields that should be selected.

client.count(model, args)

optionstypedefaultrequireddescription
modelstringnullyesModel to perform the action on.
argsarraynullnoList of parameters. Example: "id > 1", "name = Louis"

client.read(model, args, params)

optionstypedefaultrequireddescription
modelstringnullyesModel to perform the action on.
argsarraynullnoList of parameters. Example: "id > 1", "name = Louis"
params.offsetnumber0noResult offset.
params.limitnumber5noMaximum number of results.
params.orderstringidnoName of the fields used to sort the results.
params.selectstring[][]noFields that should be selected.

client.search(model, args)

optionstypedefaultrequireddescription
modelstringnullyesModel to perform the action on.
argsarraynullnoList of parameters. Example: "id > 1", "name = Louis"

client.searchRead(model, args, params)

optionstypedefaultrequireddescription
modelstringnullyesModel to perform the action on.
argsarraynullyesList of parameters. Example: "id > 1", "name = Louis"
params.offsetnumber0noResult offset.
params.limitnumber5noMaximum number of results.
params.orderstringidnoName of the fields used to sort the results.
params.selectstring[][]noFields that should be selected.

client.create(model, args)

optionstypedefaultrequireddescription
modelstringnullyesModel to perform the action on.
argsarraynullnoList of parameters. Example: "id > 1", "name = Louis"

client.call(model, method, args, params)

optionstypedefaultrequireddescription
modelstringnullyesModel to perform the action on.
methodstringnullyesOdoo RPC method.
argsarraynullyesList of parameters. Example: "id > 1", "name = Louis"
argsObjectnullnoCustom kwargs properties.

License

MIT ©

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.2

4 years ago

1.0.8

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago