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

odoo

v0.4.0

Published

Node.js client library for Odoo using JSON-RPC

Downloads

110

Readme

Odoo

Node.js client library for Odoo

Installation

$ npm install Odoo

Usage

var Odoo = require('Odoo');

var odoo = new Odoo({
  host: 'localhost',
  port: 8069,
  database: 'demo',
  username: 'admin',
  password: 'admin'
});

// Connect to Odoo
odoo.connect(function (err) {
  if (err) { return console.log(err); }
});

// Get a partner
// https://www.odoo.com/documentation/8.0/api_integration.html#read-records
// https://www.odoo.com/documentation/8.0/reference/orm.html#openerp.models.Model.read
var params = {
  ids: [1,2,3,4,5],
  fields: [ 'name' ],
}; //params
odoo.get('res.partner', params, function (err, partners) {
  if (err) { return console.log(err); }

  console.log(partners);
// [
//   { id: 1, name: 'Demo Company' },
//   { id: 3, name: 'Administrator' },
//   { id: 4, name: 'Public user' },
//   { id: 5, name: 'Demo User' }
// ]
}); //get


// Search & Get products in one RPC call
// https://www.odoo.com/documentation/8.0/api_integration.html#search-and-read
// https://www.odoo.com/documentation/8.0/reference/orm.html#openerp.models.Model.search
// https://www.odoo.com/documentation/8.0/reference/orm.html#openerp.models.Model.read
var params = {
  ids: [1,2,3,4,5],
  domain: [ [ 'list_price', '>', '50' ], [ 'list_price', '<', '65' ] ],
  fields: [ 'name', 'list_price', 'items' ],
  order: 'list_price',
  limit: 5,
  offset: 0,  
}; //params
odoo.search_read('product.product', params, function (err, products) {
  if (err) { return console.log(err); }

  console.log(products);
// [
//   { list_price: 60, id: 52, name: 'Router R430' },
//   { list_price: 62, id: 39, name: 'Headset standard' }
// ]

}); //search_read


// Browse products by ID
// Not a direct implementation of Odoo RPC 'browse' but rather a workaround based on 'search_read'
// https://www.odoo.com/documentation/8.0/reference/orm.html#openerp.models.Model.browse
var params = {
  fields: [ 'name', 'list_price'],
  limit: 5,
  offset: 0,  
}; //params
odoo.browse_by_id('product.product', params, function (err, products) {
  if (err) { return console.log(err); }

  console.log(products);
// [
//   { list_price: 4.49, id: 1180, name: 'Fruit Cup' },
//   { list_price: 0, id: 1139, name: 'Orange Crush' },
//   { list_price: 1.59, id: 1062, name: 'Blueberry muffin' },
//   { list_price: 1.35, id: 1381, name: 'Otis Harvest Bran' }
// ]
}); //browse_by_id


// Generic RPC call
// Note that, unlike the other methods, the context is not automatically included
var endpoint = '/web/dataset/call_kw';
var model = 'sale.order';
var method = 'action_view_delivery';

var args = [
  [sale_order_id],
  {
    tz: odoo.context.tz,
    uid: odoo.context.uid,
  },
];//args

var params = {
  model: model,
  method: method,
  args: args,
  kwargs: {},
};//params

// View Delivery Order
odoo.rpc_call(endpoint, params, function(err, result) {
  if(err) {
    console.log(err);
    return;
  }//if

  var delivery_order = result;

  console.log(delivery_order);
});//odoo.rpc_call

Methods

  • odoo.connect(callback)
  • odoo.get(model, id, callback)
  • odoo.search(model, params, callback)
  • odoo.search_read(model, params, callback)
  • odoo.browse_by_id(model, params, callback)
  • odoo.create(model, params, callback)
  • odoo.update(model, id, params, callback)
  • odoo.delete(model, id, callback)
  • odoo.rpc_call(endpoint, params, callback);

##Node version Works better with NodeJS v11.16 and further

Reference

License

The MIT License (MIT)

Copyright (c) 2015 Marco Godínez, 4yopping and all the related trademarks

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.