npm package: @nextocore/odoo
Description: Complete Odoo integration for Next.js - Backend-agnostic client, JSON-RPC adapter, TypeScript types, real-time sync, and mock data infrastructure
Author: ABC Food
Latest version: 1.0.0

# @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

```typescript
// 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>
}
```

```typescript
// 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

```bash
npm install @nextocore/odoo @tanstack/react-query
```

## Key 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 `any` types, full TypeScript support
- **📊 Performance Monitoring**: Built-in metrics and debugging

## Documentation

- [API Reference](./docs/API.md) - Complete API documentation
- [Migration Guide](./docs/MIGRATION.md) - v1.0.0 to v2.0.0 migration
- [Performance Guide](./docs/PERFORMANCE.md) - Optimization techniques
- [Troubleshooting](./docs/TROUBLESHOOTING.md) - Common issues and solutions
- [Examples](./examples/README.md) - Real-world implementation examples

## Available Hooks

```typescript
// 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](https://github.com/nextocore)