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 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-odoo-crud

v0.1.1

Published

A Node.js library for interacting with Odoo using the XML-RPC API.

Downloads

16

Readme

Node-Odoo-CRUD

Odoo CRUD Node.js Library

This library provides a simple interface to interact with Odoo's XML-RPC API using Node.js.

It supports basic 
 CRUD (
  Create,
 Read, 
 Update,
  Delete
  list_records
 pagination
  search_records
  ) operations on Odoo models.

Installation

First, you need to install the node-odoo-crud package, which is a dependency for this library.

Bash

 $ npm install node-odoo-crud

Then, save the provided code in a file, for example, odoo.js.

Usage

const Odoo = require('./odoo');
Configuration
Create a configuration object with the following parameters:

url: The URL of your Odoo instance.
db: The database name.
username: Your Odoo username.
password: Your Odoo password.

const config = {
  url: 'https://your-odoo-instance.com',
  db: 'your-database-name',
  username: 'your-username',
  password: 'your-password'
};

const odoo = new Odoo(config);
Connecting to Odoo
Before performing any operations, you need to connect to your Odoo instance.
 This method will authenticate the user and retrieve the
  user's unique ID (uid).

odoo.connect((error, uid) => {
  if (error) {
    console.error('Connection error:', error);
  } else {
    console.log('Connected to Odoo with UID:', uid);
    // You can now perform CRUD operations
  }
});

Creating a Record

To create a record in a specific model:

const model = 'res.partner';
const data = {
  name: 'your odoo name',
  email: 'your odoo  email'
};

odoo.createRecord(model, data, (error, recordId) => {
  if (error) {
    console.error('Create record error:', error);
  } else {
    console.log('Record created with ID:', recordId);
  }
});

Reading Records

To read records from a specific model with a given domain:

const model = 'res.partner';
const domain = [['is_company', '=', true]];

odoo.readRecords(model, domain, (error, records) => {
  if (error) {
    console.error('Read records error:', error);
  } else {
    console.log('Records:', records);
  }
});

Updating a Record

To update a specific record in a model:

const model = 'res.partner';
const recordId = 1;  // Replace with the actual record ID
const data = {
  email: 'Your odoo email'
};

odoo.updateRecord(model, recordId, data, (error, success) => {
  if (error) {
    console.error('Update record error:', error);
  } else {
    console.log('Record updated:', success);
  }
});

Deleting a Record

To delete a specific record from a model:

const model = 'res.partner';
const recordId = 1;  // Replace with the actual record ID

odoo.deleteRecord(model, recordId, (error, success) => {
  if (error) {
    console.error('Delete record error:', error);
  } else {
    console.log('Record deleted:', success);
  }
});

License

This project is licensed under the MIT License.

Notes

Ensure that the node-odoo-crud package is installed and available in your project.
The config object should contain valid credentials and URLs for your Odoo instance.
Adjust the model names and fields in the examples according to your Odoo setup.
Feel free to modify and expand the library to suit your specific needs.

Thank You !