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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@marcfargas/odoo-introspection

v0.1.3

Published

TypeScript introspection and code generation for Odoo models

Readme

@marcfargas/odoo-introspection

TypeScript introspection and code generation for Odoo models.

Features

  • Runtime Introspection: Query Odoo's ir.model and ir.model.fields to discover models and their schemas
  • Type Generation: Automatically generate TypeScript interfaces from live Odoo metadata
  • Field Type Mapping: Intelligent mapping of Odoo field types to TypeScript types
  • Caching: Built-in caching to minimize RPC calls
  • CLI Tool: Command-line tool for easy code generation

Installation

npm install @marcfargas/odoo-introspection @marcfargas/odoo-client

Prerequisites: Node.js ≥ 18, a running Odoo v17 instance.

Quick Start

Programmatic Usage

import { createClient } from '@marcfargas/odoo-client';
import { Introspector } from '@marcfargas/odoo-introspection';

// Reads ODOO_URL, ODOO_DB, ODOO_USER, ODOO_PASSWORD from env
const client = await createClient();

// Create introspector
const introspector = new Introspector(client);

// Get all models
const models = await introspector.getModels();
console.log(models.map(m => m.model)); // ['res.partner', 'sale.order', ...]

// Get fields for a model
const fields = await introspector.getFields('res.partner');

// Get complete metadata
const metadata = await introspector.getModelMetadata('res.partner');
console.log(metadata.model.name);    // 'Contact'
console.log(metadata.fields.length); // 50+

CLI Usage

# Basic generation
odoo-introspect generate \
  --url http://localhost:8069 \
  --db odoo_dev \
  --password admin \
  --output src/models

# With options
odoo-introspect generate \
  --url http://localhost:8069 \
  --db odoo_dev \
  --password admin \
  --output src/models \
  --modules sale,project \
  --include-transient

# Via environment variables
export ODOO_URL=http://localhost:8069
export ODOO_DB=odoo_dev
export ODOO_PASSWORD=admin

odoo-introspect generate --output src/models

API

Introspector Class

Constructor

new Introspector(client: OdooClient)

Methods

getModels(options?)

Retrieve all available models.

const models = await introspector.getModels({
  includeTransient: false,  // Include wizard models
  modules: ['sale'],        // Filter by modules
  bypassCache: false        // Force fresh query
});

Returns: Promise<OdooModel[]>

getFields(modelName, options?)

Retrieve all fields for a model.

const fields = await introspector.getFields('res.partner');

Returns: Promise<OdooField[]>

getModelMetadata(modelName, options?)

Retrieve complete metadata (model + fields).

const metadata = await introspector.getModelMetadata('res.partner');

Returns: Promise<ModelMetadata>

clearCache()

Clear all cached introspection data.

introspector.clearCache();
clearModelCache(modelName)

Clear cached data for a specific model.

introspector.clearModelCache('res.partner');

CodeGenerator Class

Generate TypeScript interfaces from Odoo schemas.

import { CodeGenerator } from '@marcfargas/odoo-introspection';

const generator = new CodeGenerator(client);

const code = await generator.generate({
  outputDir: './src/models',
  includeTransient: false,
  modules: undefined,
  bypassCache: false
});

Generated Code

The code generator produces TypeScript interfaces like:

/**
 * Contact
 * 
 * Odoo Model: res.partner
 */
export interface ResPartner {
  /**
   * Name
   * @required
   */
  name: string;

  /**
   * Email
   */
  email?: string;

  /**
   * Customer
   */
  customer: boolean;

  // ... more fields
}

Type Mapping

Odoo field types are mapped to TypeScript as follows:

| Odoo Type | TypeScript Type | |-----------|-----------------| | char, text, html | string | | integer | number | | float, monetary | number | | boolean | boolean | | date, datetime | string (ISO 8601) | | many2one | number | | one2many, many2many | number[] | | selection | string | | binary | string |

Caching

Introspection results are cached in memory to minimize RPC overhead. Cache is automatically managed:

  • Models are cached after the first getModels() call
  • Fields are cached per-model after each getFields() call
  • Combined metadata is cached after getModelMetadata() calls

Use bypassCache: true to force a fresh query, or call clearCache() to reset all caches.

Logging

This package uses the debug library for logging. Enable debug output:

# All odoo-toolbox logging
DEBUG=odoo-* npm run test

# Only introspection logging
DEBUG=odoo-introspection:* npm run test

# Specific modules
DEBUG=odoo-introspection:introspection,odoo-introspection:codegen npm run test

Tested Examples

For comprehensive, tested examples of introspection patterns and model discovery, see the knowledge modules.

Related Packages

Bugs & Support

GitHub Issues

License

LGPL-3.0 — see LICENSE