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

apidoo

v2.0.1

Published

Odoo API

Downloads

11

Readme

Apidoo

Odoo API async requests

Installing

Using npm:

$npm i apidoo --save

Important

If you are working with js framworks (react, vue, angular, svelte, etc) you need to integrate proxys

  • Add the following 3 routes to the file vite.config.js
export default defineConfig({
  ...
  server: {
    ...
    proxy: {
      ...
      '/web/session/authenticate': {
        target: 'http://localhost:8069/web/session/authenticate',
        rewrite: (path) => path.replace('/web/session/authenticate', ''),
      },
      '/web/session/get_session_info': {
        target: 'http://localhost:8069/web/session/get_session_info',
        rewrite: (path) => path.replace('/web/session/get_session_info', ''),
      },
      '/web/dataset/call_kw': {
        target: 'http://localhost:8069/web/dataset/call_kw',
        rewrite: (path) => path.replace('/web/dataset/call_kw', ''),
      },
     ...
    }
  }
})
  • Install the package http-proxy-middleware ($npm i http-proxy-middleware)
  • Create the file setupProxy.js inside src/ folder
  • Restart the server
const { createProxyMiddleware } = require('http-proxy-middleware');

const session_info = {
    target: 'http://localhost:8069',
    changeOrigin: true
}
const authenticate = {
    target: 'http://localhost:8069',
    changeOrigin: true
}
const call_kw = {
    target: 'http://localhost:8069',
    changeOrigin: true
}

module.exports = function(app) {
  app.use(
    '/web/session/get_session_info',
    createProxyMiddleware(session_info)
  );

  app.use(
    '/web/session/authenticate',
    createProxyMiddleware(session_info)
  );
  app.use(
    '/web/dataset/call_kw', 
    createProxyMiddleware(call_kw)
  );
};
  • WIP

Usage

    // You should pass an empty string as url because you already define the url in the proxy configuration
    import Apidoo from 'apidoo'
    let odoo = new Apidoo('', 'db', 'user', 'password')
    await odoo.connect()

    // Search all partners
    let partner = odoo.env('res.partner')
    let response = await parter.search()

Methods

Env and Context

    // New res partner model env
    let partner = odoo.env('res.partner')

    // Search partners with a context
    let partner_ids = await partner.with_context({lang : 'es_ES'}).search()
    

Search

    let partner = odoo.env('res.partner')

    // Search partner with a domain and attributes
    let partner_ids = await partner.search(
      [['active', '=', false]], 
      { limit: 2, offset: 1, order: 'name,email desc'}
    )

Search Count

    let partner = odoo.env('res.partner')

     // Count partners with a domain
    let partners_count = await partner.search_count([
      ['active', '=', false]]
    )

Read

    let partner = odoo.env('res.partner')

    // Search ative partners ids
    let partner_ids = await partner.search(
      [['active', '=', false]]
    )

    // Read fields name and title from partner_ids
    let partners = await partner.read(
      [partner_ids],
      { fields: ['name', 'title']}
    )

Search Read

    let partner = odoo.env('res.partner')

    // Search partner with a domain and get custom fields. This is a mix from Search and Read
    let partners = await partner.search_read(
      [['active', '=', false]], 
      { fields: ['name'] }
    )
  

Get Fields

    let partner = odoo.env('res.partner')

    // Get all fields from res.partner model
    let partner_fields_all = await partner.get_fields()

    // Get the the type ad string attributes from title field from res.partner model 
    let partner_fields = await partner.get_fields(
      ['title'],
      { attributes: ['type', 'string'] }
    )
   

Session

    import Apidoo from 'apidoo'
    // Get the session info
    let odoo = new Apidoo('', 'db', 'user', 'password')
    await odoo.connect()

    odoo.auth.session_info