@nextocore/odoo
v1.0.0
Published
Complete Odoo integration for Next.js - Backend-agnostic client, JSON-RPC adapter, TypeScript types, real-time sync, and mock data infrastructure
Maintainers
Readme
@nextocore/odoo
Optimal React Query hooks for Odoo integration - Enterprise-ready with advanced caching, real-time sync, and comprehensive error handling.
Version: 2.0.0 | 100% Test Coverage | Production Ready
Quick Start
// app/providers.tsx
'use client'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { initializeOdooClient, OdooAdapter } from '@nextocore/odoo'
const queryClient = new QueryClient()
const odooAdapter = new OdooAdapter({
url: process.env.NEXT_PUBLIC_ODOO_URL!,
database: process.env.NEXT_PUBLIC_ODOO_DB!,
auth: { /* your auth config */ }
})
initializeOdooClient(odooAdapter, queryClient)
export function Providers({ children }: { children: React.ReactNode }) {
return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
}// app/customers/page.tsx
'use client'
import { useOdooSearch, useOdooCreate } from '@nextocore/odoo'
export default function CustomersPage() {
const { data: customers, isLoading } = useOdooSearch('res.partner', {
where: { customer_rank: { gt: 0 } },
limit: 20
})
const createMutation = useOdooCreate({
onSuccess: () => console.log('Customer created')
})
if (isLoading) return <div>Loading...</div>
return (
<div>
{customers?.map(customer => (
<div key={customer.id}>{customer.name}</div>
))}
<button onClick={() => createMutation.mutate({
model: 'res.partner',
data: { name: 'New Customer', is_company: true }
})}>
Add Customer
</button>
</div>
)
}Installation
npm install @nextocore/odoo @tanstack/react-queryKey Features
- 🔥 React Query Integration: First-class hooks with intelligent caching
- ⚡ Optimistic Updates: Automatic rollback on errors
- 🔄 Real-time Subscriptions: WebSocket/SSE/Polling support
- 💾 Multi-layer Caching: Memory + IndexedDB + Redis
- 🛡️ Type Safety: Zero
anytypes, full TypeScript support - 📊 Performance Monitoring: Built-in metrics and debugging
Documentation
- API Reference - Complete API documentation
- Migration Guide - v1.0.0 to v2.0.0 migration
- Performance Guide - Optimization techniques
- Troubleshooting - Common issues and solutions
- Examples - Real-world implementation examples
Available Hooks
// Query hooks
const { data } = useOdooSearch('res.partner', { limit: 20 })
const { data: record } = useOdooRecord('res.partner', 123, ['name', 'email'])
const { data: count } = useOdooCount('res.partner', { active: true })
const { data, fetchNextPage } = useOdooInfiniteSearch('sale.order', { limit: 20 })
// Mutation hooks
const createMutation = useOdooCreate()
const updateMutation = useOdooUpdate()
const deleteMutation = useOdooDelete()License
MIT © ABC Food
