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

nuxt-odoo

v1.3.4

Published

Nuxt module for odoo call

Readme

🚀 Nuxt Odoo Plugin

An advanced Nuxt 3 plugin for Odoo ERP integration that supports both static mode (ssr: false) and server mode (ssr: true).

✨ Features

  • 🔄 Adaptive Mode: Works automatically with both static and server-side builds
  • 🔐 Complete Authentication: Login/logout with session management
  • 📡 Complete API: All Odoo methods (CRUD, readGroup, searchRead, etc.)
  • 🛡️ Error Handling: Automatic handling of expired sessions
  • 🎯 Type Safety: Full TypeScript support
  • Performance: Optimized for both deployment modes

📦 Installation

npm install nuxt-odoo

⚙️ Configuration

1. Add the module to nuxt.config.ts:

export default defineNuxtConfig({
  modules: [
    'nuxt-odoo'
  ],
  odooRpc: {
    baseUrl: process.env.BASE_URL,    // Odoo server URL
    dbName: process.env.DB_NAME,      // Odoo database name
  },
  ssr: false, // For static mode (optional)
})

2. Environment variables (.env):

BASE_URL=https://your-odoo-server.com
DB_NAME=your-database-name

🎯 Basic Usage

Authentication

// pages/login.vue
<script setup>
const { $odoo } = useNuxtApp()

const login = async () => {
  try {
    const result = await $odoo.login('database', 'username', 'password')
    localStorage.setItem('session_id', result.session_id)
    // Login successful
  } catch (error) {
    // Error handling
  }
}
</script>

CRUD Operations

// Service example
const userService = {
  // Search and read
  getUsers: async () => {
    return await $odoo.searchRead('res.users', {
      domain: [['active', '=', true]],
      fields: ['name', 'email', 'login']
    })
  },

  // Create
  createUser: async (userData) => {
    return await $odoo.create('res.users', userData)
  },

  // Update
  updateUser: async (userId, userData) => {
    return await $odoo.write('res.users', userId, userData)
  },

  // Delete
  deleteUser: async (userId) => {
    return await $odoo.unlink('res.users', userId)
  }
}

Aggregations with readGroup

// Example for dashboard/analytics
const dashboardService = {
  getStats: async () => {
    return await $odoo.readGroup('sale.order', [], {
      groupby: ['state', 'date_order:month'],
      fields: ['amount_total', 'state'],
      domain: [['date_order', '>=', '2024-01-01']],
      lazy: false
    })
  }
}

🔧 Complete API

Authentication Methods

  • login(db, username, password) - User authentication
  • logout() - User logout
  • isLoggedIn() - Check login status
  • sendSession(sessionId) - Initialize existing session

CRUD Methods

  • create(model, data, params) - Create record
  • read(model, ids, params) - Read record
  • write(model, ids, data, params) - Update record
  • unlink(model, ids, params) - Delete record

Search Methods

  • search(model, params) - Search IDs
  • searchRead(model, params) - Search and read
  • searchCount(model, params) - Count results

Advanced Methods

  • readGroup(model, args, kwargs) - Aggregations
  • fieldsGet(model, params) - Field metadata
  • call(model, method, args, kwargs) - Custom calls

🏗️ Operating Modes

📱 Static Mode (ssr: false)

// nuxt.config.ts
export default defineNuxtConfig({
  ssr: false,  // Generate static files
  // ... rest of configuration
})

Features:

  • ✅ Deploy on CDN/static hosting
  • ✅ Direct calls to Odoo web APIs
  • ✅ Client-side session management
  • ✅ High performance

🖥️ Server Mode (ssr: true)

// nuxt.config.ts  
export default defineNuxtConfig({
  ssr: true,  // Server-side rendering
  // ... rest of configuration
})

Features:

  • ✅ SEO optimized
  • ✅ Nuxt server handlers
  • ✅ Server-side session management
  • ✅ Advanced security

🎨 Practical Examples

Dashboard with Charts

// composables/useProductionStats.ts
export function useProductionStats() {
  const { $odoo } = useNuxtApp()
  
  const getProductionData = async () => {
    return await $odoo.readGroup('production.order', [], {
      groupby: ['state', 'date_planned:day'],
      fields: ['product_qty', 'state'],
      domain: [['date_planned', '>=', useTodayDate()]],
      lazy: false
    })
  }
  
  return { getProductionData }
}

Inventory Management

// services/inventoryService.ts
const inventoryService = {
  getStock: async (locationId) => {
    return await $odoo.searchRead('stock.quant', {
      domain: [['location_id', '=', locationId]],
      fields: ['product_id', 'quantity', 'reserved_quantity']
    })
  },

  moveStock: async (productId, fromLocation, toLocation, quantity) => {
    return await $odoo.call('stock.move', 'create_and_confirm', [], {
      product_id: productId,
      location_id: fromLocation,
      location_dest_id: toLocation,
      product_uom_qty: quantity
    })
  }
}

🚨 Error Handling

// middleware/auth.global.ts
export default defineNuxtRouteMiddleware((to) => {
  if(process.server) return

  const sessionId = window.localStorage.getItem('session_id')

  if (sessionId && to?.name === 'login') {
    return navigateTo('/')
  }

  if (!sessionId && to?.name !== 'login') {
    abortNavigation()
    return navigateTo('/login')
  }
})

📚 Advanced Documentation

Custom Context

// Pass custom context
await $odoo.searchRead('res.partner', {
  domain: [],
  fields: ['name'],
  context: { lang: 'it_IT', tz: 'Europe/Rome' }
})

Pagination

// Paginated search
await $odoo.searchRead('product.product', {
  domain: [['sale_ok', '=', true]],
  fields: ['name', 'list_price'],
  offset: 0,
  limit: 50,
  order: 'name ASC'
})

🤝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

MIT License - see LICENSE for details.

🙏 Credits


Made with ❤️ for the Odoo & Nuxt communities