npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@keyzar/odoo-js

v1.1.2

Published

an Odoo Javascript Libraries for connecting to Odoo via Odoo JSON API

Readme

Odoo JS Connector

This is a lightweight JavaScript/TypeScript library for connecting to an Odoo instance via its JSON/2 endpoint. It provides a simple and intuitive API for interacting with your Odoo models.

Installation

npm install odoo-js-connector

Usage

Initialization

First, you need to create an instance of the Odoo class with your Odoo configuration.

import { Odoo } from 'odoo-js-connector';

const odoo = new Odoo({
  baseUrl: 'https://your-odoo-instance.com',
  apiKey: 'your-api-key'
});

Creating records

To create a new record for a model, you can use the create method on a Model instance.

const model = odoo.model('res.partner');

model.create({ name: 'New Partner' })
  .then(result => {
    console.log('Created record:', result);
  })
  .catch(error => {
    console.error('Error creating record:', error);
  });

Searching records

You can search for records using the search_read method. It takes a domain to filter the records and a list of fields to return.

const model = odoo.model('res.partner');

model.search_read([['is_company', '=', true]], ['name', 'email'])
  .then(result => {
    console.log('Found records:', result);
  })
  .catch(error => {
    console.error('Error searching records:', error);
  });

Updating records

To update a record, you first need to get a ModelExecutable instance by calling the id method with the record's ID. Then you can use the write method to update the record.

const model = odoo.model('res.partner');

model.id(123).write({ name: 'Updated Partner Name' })
  .then(() => {
    console.log('Record updated successfully');
  })
  .catch(error => {
    console.error('Error updating record:', error);
  });

API Reference

Odoo class

constructor(configuration: OdooConfig)

Creates a new Odoo instance.

  • configuration: An object with the following properties:
    • baseUrl: The base URL of your Odoo instance.
    • apiKey: Your Odoo API key.

model(modelName: string): Model

Returns a Model instance for the specified model.

  • modelName: The name of the Odoo model (e.g., 'res.partner').

Model class

id(id: number): ModelExecutable

Returns a ModelExecutable instance for the record with the specified ID.

  • id: The ID of the record.

create(data: any): Promise<any>

Creates a new record for the model.

  • data: An object containing the values for the new record.

search_read(domains: SearchDomain[], fields: string[]): Promise<any>

Searches for records and returns the specified fields.

  • domains: An array of domains to filter the records. A domain is an array of three elements: [field, operator, value].
  • fields: An array of field names to return for the found records.

ModelExecutable class

write(data: any): Promise<void>

Updates the record.

  • data: An object containing the fields to update and their new values.