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

odoojs

v16.0.17

Published

odoojs is a jsonrpc for odoo

Downloads

20

Readme

odoojs-rpc

A Javascript Lib to connet odoo. Used to Create Web Application.

contact us: [email protected]

handbook

  1. go https://www.npmjs.com/package/odoojs?activeTab=code
  2. the folder: test_rpc
  3. all files in test_rpc

Usage

init

  1. before use odoojs. should init.
  2. then use api anywhere
import rpc from 'odoojs'
export const baseURL = 'http://127.0.0.1:8069'
export const timeout = 50000
export function messageError(error) {
  console.log('axios error: ', error.data.message)
}
rpc.init({ baseURL, timeout, messageError })

connect odoo, get version_info

import rpc from 'odoojs'
async function test_version_info() {
  const result = await rpc.web.webclient.version_info()
  console.log(result)
}

test_version_info()
// here is function result
const result = {
  server_version: '16.0-20230213',
  server_version_info: [16, 0, 0, 'final', 0, ''],
  server_serie: '16.0',
  protocol_version: 1
}

login odoo

import rpc from 'odoojs'

async function test_login() {
  const db = 'odoojs'
  const login = 'admin'
  const password = 'odoojs'
  const kw = { db, login, password }
  const info = await rpc.web.login(kw)
  const result = await rpc.session_check()
  await rpc.web.logout()
}

model api. CRUD

async function test_model() {
  const ptn = rpc.env.model('res.partner')
  const fields_info = await ptn.fields_get(
    ['name', 'is_company', 'parent_id', 'child_ids', 'category_id'],
    ['name', 'type']
  )
  const records = await ptn.search_read({
    domain: [['name', 'like', 'Admin']],
    fields: ['name', 'ref', 'is_company', 'child_ids', 'category_id']
  })
  const ids = await ptn.search([['name', 'like', 'Admin']])
  const res_id = ids[0]
  const record = await ptn.read_one(res_id, { fields: ['name', 'ref'] })
  const write_result = await ptn.write(res_id, { ref: 'ref_code' })
  const res_id2 = await ptn.create({ name: 'partner_name' })
  const unlink_result = await ptn.unlink(res_id2)
}

api of odoojs model


const partner_obj = rpc.env.model('res.partner')

partner_obj.search_read({domain, fields})
partner_obj.read(res_id, fields)
partner_obj.onchange(...)
partner_obj.create(vals_or_valslist)
partner_obj.write(res_id, vals)
partner_obj.unlink(res_id_or_ids)
partner_obj.name_search
partner_obj.name_get

env api.


rpc.env.model(model_name)
rpc.env.ref(xml_ref)
rpc.treeview(action_id)
rpc.formview(action_id)

api of odoojs viewmodel


// prepare action info and view info
// then

const treeview = rpc.env.treeview(action_id)
await treeview.load_fields()
const result = await treeview.search_read()

const formview = rpc.env.formview(action_id)
await formview.load_fields()
const record = await formview.read(res_id)

const value = {}
const value_display = formview.set_editable({record, value})
const {values} = await formview.onchange(fieldname, value)
const res_id = await formview.commit()

api of odoojs viewmodel one2many field

const formview = rpc.env.formview(action_id)
await formview.load_fields()
const fields_info = formview.fields
const record = await formview.read(res_id)
const relation_fieldinfo = fields_info[relation_field_name]
const o2m_ids = record[relation_field_name]
const relation = rpc.env.relation(relation_fieldinfo)
const o2mtree = relation.tree
const records = await o2mtree.read(o2m_ids)
o2mtree.pick_one
const o2mform = relation.form
const {values} = await o2mform.onchange()
o2mform.commit()
o2mtree.upinsert_one
await formview.onchange(relation_field_name, value)
await formview.commit()